Skip to content

Commit

Permalink
Add support for unicode regular expression flag
Browse files Browse the repository at this point in the history
The regular expression for matching valid JS regular expressions seems to be missing the `u` flag, which is a valid flag to treat a pattern as a sequence of unicode code points.

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags_2
  • Loading branch information
merty authored and matthiasmullie committed Apr 4, 2018
1 parent 04a37f5 commit 2e54f84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected function extractRegex()
// closing the regex)
// then also ignore bare `/` inside `[]`, where they don't need to be
// escaped: anything inside `[]` can be ignored safely
$pattern = '\\/(?:[^\\[\\/\\\\\n\r]+|(?:\\\\.)+|(?:\\[(?:[^\\]\\\\\n\r]+|(?:\\\\.)+)+\\])+)++\\/[gimy]*';
$pattern = '\\/(?:[^\\[\\/\\\\\n\r]+|(?:\\\\.)+|(?:\\[(?:[^\\]\\\\\n\r]+|(?:\\\\.)+)+\\])+)++\\/[gimuy]*';

// a regular expression can only be followed by a few operators or some
// of the RegExp methods (a `\` followed by a variable or value is
Expand Down

0 comments on commit 2e54f84

Please sign in to comment.