RegExp deviation from Perl 5 - By Design or Spec Bug?

Erik Corry erik.corry at gmail.com
Wed Jan 19 14:13:29 PST 2011


2011/1/19 Dave Fugate <dfugate at microsoft.com>:
> I’ve come across the following RegExp scenario:
>
>                 /\s^/m.test("\n")
>
>
>
> which results in true, yet the equivalent in Perl 5:
>
> "\n" =~ m/\s^/m
>
>
>
> yields false.
>
>
>
> It seems that the JavaScript implementations I tested against are correctly
> implementing ES5.  That is, 15.10.2.6, step 4 states that if the character
> before the current endIndex is a newline then return true. After matching
> the \s, the previous character is indeed a newline, so the assertion
> succeeds.
>
>
>
> Am I misinterpreting ES5 here and the implementations are exhibiting
> incorrect behavior *or* is the spec not matching Perl 5?  If it’s the
> latter, would this be considered a spec defect as ES5’s RegExp feature is
> roughly a subset of Perl 5?

There are quite a few places where ES differs from perl.

Why is it that perl does not match here?

-- 
Erik Corry


More information about the es-discuss mailing list