RegExp deviation from Perl 5 - By Design or Spec Bug?
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? Thanks! Dave ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp deviation from Perl 5 - By Design or Spec Bug?
2011/1/19 Dave Fugate dfug...@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 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp deviation from Perl 5 - By Design or Spec Bug?
On Wed, Jan 19, 2011 at 2:13 PM, Erik Corry erik.co...@gmail.com wrote: 2011/1/19 Dave Fugate dfug...@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? If you consider perlre perldoc to be a spec, then Perl5 makes an explicit exemption for newline which is the last character: You may, however, wish to treat a string as a multi-line buffer, such that the ^ will match after any newline within the string (except if the newline is the last character in the string), and $ will match before any newline. Perl6 deprecates the /m multiline modifier, changes the semantics of ^ and $ and introduces ^^ and $$. -- Erik Corry ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss