webidl
webidl copied to clipboard
Decimal regular expression has “dead code” (so to speak)
In /-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/
— er, wait, I think this will be a little easier to see if we translate to an idiomatic ES pattern first. In
/-?((\d+\.\d*|\d*\.\d+)(E[+-]?\d+)?|\d+E[+-]?\d+)/i
the second \d*
can only ever match the empty string (\d{0,0}
) because \d+\.\d*
(\d{1,∞}\.\d{0,∞}
) is inclusive of \d+\.\d+
(\d{1,∞}\.\d{1,∞}
). As it “does nothing”, it seems clearer to not include it:
/-?((\d+\.\d*|\.\d+)(E[+-]?\d+)?|\d+E[+-]?\d+)/i
We should change these to be JS regular expressions at the same time. No need for a Perl 5 dependency.