Closed tomwyatt closed 4 years ago
@tomwyatt Can you please explain what you are trying to do with the regular expression?
Is it possible you mean to use {0,5}
with a comma? I don't recognize a period there as a valid regular expression.
@awwright I am using 'jsonschema.validate' to validate some value against the provided pattern. You are right that .{0,5} would make more sense to use than .{0.5}. When no unicode flag is present, the javascript regex engine may be interpreting the pattern as literal characters.
In version 1.2.6, .{0.5} (using a dot, rather than comma) worked as a valid pattern.
var expr = new RegExp('.{0.5}');
With the flag added to this line, the pattern is no longer valid and throws when trying to create the expression.
@tomwyatt What is the pattern trying to match? Any 5 characters? Something else?
As far as I can tell, .{0.5}
never matches anything.
a{0a5} would match this pattern. The 0,5 and {} are interpreted as literal characters when using the .{0.5} regex. It may not be the best pattern; a test was using it unintentionally and began failing with the new version, as the line which creates the RegExp throws with this pattern and the unicode flag.
@tomwyatt Alright you convinced me, I just fixed this in 01fb6f857b52f517ec70037c581c9922ea43a1eb and dropped 1.2.9
See also #311
There has been a recent change to include the unicode flag when creating a RegExp from a provided valid pattern and validating this expression. With the new flag added, the pattern is no longer acceptable as a pattern input.
var expr = new RegExp(pattern, 'u');
Input pattern:
.{0.5}
Output:
SyntaxError: Invalid regular expression: /.{0.5}/: Incomplete quantifier