Skip to content

Commit 4aecb56

Browse files
committed
Fix scala-js#3134: Make regex.Matcher report correct group positions.
To compute the correct group positions (which are not computed by javascript), GroupStartMap modifies the regular expression so that every part of the regex belongs to a group. Based on the length of every group, we can recover the start position of the original group. Example: If the regex /A(B)\1/ matches a string at a given index, then /(A)(B)\2/ matches the same string at the same index. However, in the second regex, we can use the length of the first group (A) to retrieve the start position of the second group (B). Note that the back-references in the second regex are shifted, but this does not change the matched strings.
1 parent 9b4de23 commit 4aecb56

File tree

3 files changed

+722
-45
lines changed

3 files changed

+722
-45
lines changed

0 commit comments

Comments
 (0)