silverme / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

RegGrp messes up non-capturing matches #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using RegGrp with non-capturing matches /(?:red\s+)/, the replacements
after the non-captured submatch get mixed up. See testcase.

Original issue reported on code.google.com by doek...@gmail.com on 9 Jun 2007 at 8:33

GoogleCodeExporter commented 8 years ago
Oops, forgot to attach the test-case.

Original comment by doek...@gmail.com on 9 Jun 2007 at 8:36

Attachments:

GoogleCodeExporter commented 8 years ago
Defect solved in subversion. /lib/ is not updated, however.

Original comment by doek...@gmail.com on 9 Jun 2007 at 8:39

GoogleCodeExporter commented 8 years ago

Original comment by doek...@gmail.com on 14 Jul 2007 at 7:07

GoogleCodeExporter commented 8 years ago
I'm re-opening this bug. The referenced source module is RegGrp/Item.js. The
checked-in solution has two failings:

1. the RegExp /\((?!\?)/ does not compile on IE5.0
2. the RegExp /\((?!\?)/ does not match sub-queries correctly:
   e.g. var number = /\b[+-]?(\d*\.?\d+|\d+\.?\d*)([eE][+-]?\d+)?\b/;
        new RegGrp.Item(number, "").length; // => 1 (should be 2)

Original comment by dean.edw...@gmail.com on 15 Jul 2007 at 11:28

GoogleCodeExporter commented 8 years ago
Fixed the issue with a basic RegExp, so IE5 should be OK.
The number now also has a length of 2.

BTW: What's wrong with a JSON number: /^\-?(0|[1-9]\d*)(\.\d+)?([eE][-+]?\d+)?$/

Original comment by doek...@gmail.com on 16 Jul 2007 at 6:21