/\1/ could be a valid RegExp through Chapter 16 Extension clause?

Mike Samuel mikesamuel at gmail.com
Wed Jul 6 18:52:25 PDT 2011


2011/7/6 Dave Fugate <dfugate at microsoft.com>:
>                 var x = /\1/;
>
>
>
> According to 15.10.2.11, the RegExp snippet above should throw something as
> there aren’t any capturing parenthesis within the RegExp, yet one is
> referenced.  Just now noticed that step 4 of 15.10.2.9 is more precise and
> shows a SyntaxError gets thrown.  Isn’t the snippet then potentially valid
> ES5 code through Chapter 16’s SyntaxError extension clause?


Yes, by the extension, and whether a \<octal> is a backreference or an
octal escape sequence is determined by whether there are
parseInt(<octal>, 10) capturing groups to the left of it in the
regular expression.
So
    /\1(foo)\1/
matches the same language as
   /\u0001(foo)\1/
but does not match the same language as
   /\u0001(foo)\u0001/

>
> Thanks!
>
>
>
> Dave
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


More information about the es-discuss mailing list