Skip to content

Commit b5d03c0

Browse files
scopalecthomas
authored andcommitted
feat(regexlexer): compile in RE2 compatibility mode
To better match vanilla Go regexps and support some additional constructs that might be present in Pygments rules. https://github.com/dlclark/regexp2#re2-compatibility-mode
1 parent 4d45300 commit b5d03c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: regexp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (r *RegexLexer) maybeCompile() (err error) {
404404
pattern = "(?" + rule.flags + ")" + pattern
405405
}
406406
pattern = `\G` + pattern
407-
rule.Regexp, err = regexp2.Compile(pattern, 0)
407+
rule.Regexp, err = regexp2.Compile(pattern, regexp2.RE2)
408408
if err != nil {
409409
return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err)
410410
}

0 commit comments

Comments
 (0)