News for hackers. Stuff that matters.
Re:Perl 5.26.0 released by rcthompson on Thursday June 01, 2017 @08:09AM (#14459573)
Perl is still the only language I've seen that has a dedicated syntax for regular expressions. Every other language requires you to write your regexes as strings, which puts you squarely in backslash hell.

(I'm sure there must be other languages with dedicated regex syntax, but I'm not aware of any.)

Re:Perl 5.26.0 released by cutler on Thursday June 01, 2017 @08:17AM (#14459618)
Ruby is a direct descendant of Perl and borrows its regex syntax.
Re:Perl 5.26.0 released by MadcapJake on Thursday June 01, 2017 @11:08AM (#14460861)
Ruby used Oniguruma (and now Onigmo) for RegEx https://github.com/k-takata/Onigmo
Re:Perl 5.26.0 released by dragonwriter on Thursday June 01, 2017 @12:41PM (#14461884)
Yes (well, for MRI at least; I'm not sure other implemebtations use the same regex engine) and it used a different regex engine before Oniguruma. But engines and syntax are unrelated; Ruby has a dedicated regex literal syntax which was directly inspired by Perl.
Re:Perl 5.26.0 released by cutler on Thursday June 01, 2017 @01:00PM (#14462090)
As far as I can make out these regex engines are very close to Perl5.
Re:Perl 5.26.0 released by Ardren on Thursday June 01, 2017 @08:20AM (#14459630)
Javascript has regex literals

    /foo\sbar/i;
Is the same as:

    new RegExp('foo\\sbar', 'i');
Re:Perl 5.26.0 released by hoytech on Thursday June 01, 2017 @08:52AM (#14459796)
One thing that annoys me a bit about the JS syntax though: As far as I know, JS regexp literals don't have custom delimiter support. For instance in perl you can do this:

    $str =~ m{/some/path/\w+}
But in JS you need to escape the / characters, or use a normal string as an argument to Regexp, in which case you need to escape the backslashes:

    /\/some\/path\/\w+/
    Regexp("/some/path/\\w+")
Re:Perl 5.26.0 released by cesarb on Thursday June 01, 2017 @10:28AM (#14460523)
Some other languages have a "raw string" syntax which disables backslash processing. For instance, Python (see https://docs.python.org/3/library/re.html and https://docs.python.org/3/reference/lexical_analysis.html#st...) and Rust (see https://doc.rust-lang.org/reference/tokens.html#raw-string-l...).
Re:Perl 5.26.0 released by dragonwriter on Thursday June 01, 2017 @12:39PM (#14461867)
> Perl is still the only language I've seen that has a dedicated syntax for regular expressions.

So, you've never seen Ruby?

Re:Perl 5.26.0 released by rcthompson on Saturday June 03, 2017 @10:16AM (#14476473)
I've done a very small about of ruby programming which did not involve regular expressions.
Re:Perl 5.26.0 released by ilkkao on Thursday June 01, 2017 @08:17AM (#14459617)
Javascript is like Perl: /foo/i.test('foobar') is valid JS.