RESOLVED INVALID35856
'\d' passed to the RexExp::create as 'd'
https://bugs.webkit.org/show_bug.cgi?id=35856
Summary '\d' passed to the RexExp::create as 'd'
Balazs Kelemen
Reported 2010-03-08 02:37:20 PST
'123xyz'.match(new RegExp('^\d+')) does not find a match. When I set a breakpoint into RegExp::create I saw that it gets the pattern as '^d'. This problem is hidden by the expected.html from the regtests. I think this can be a parser (maybe lexer) bug or a bug of the bytecode generating.
Attachments
Mark Rowe (bdash)
Comment 1 2010-03-08 11:04:35 PST
How is this not expected behavior? The JavaScript string literal ‘^\d+’ is treated same as ‘^d+’ since \d is not a recognized escape sequence. This happens long before regular expressions enter the picture. If you want the \d to be treated as the regular expression meta-character you need to to escape the backslash so that the string contains the characters \ and d in sequence, e.g, ‘^\\d+’.
Alexey Proskuryakov
Comment 2 2010-03-08 12:32:01 PST
For those curious about Firefox behavior, it's the same.
Balazs Kelemen
Comment 3 2010-03-09 03:05:29 PST
I had misinterpreted this regtest result: 'abc 123xyz'.match(new RegExp('^\d+')) = null FAILED! expected: 123 Sorry for my thoughtlessness.
Note You need to log in before you can comment on or make changes to this bug.