"Errors" in regular expressions?
Opened this issue · 0 comments
When I was trying to testdrive DNSIM use GNU Octave about a month ago, one of the discrepancies I encountered was with two of the regular expressions in matlab/functions/get_search_space.m
's subfunction parse_spec
. Octave complained about:
- the "numeric_array" regex (the second one):
^([-+]?\[)[\d\s:-+]*\]$
- the "bracketed_strings" regex:
^\[[\w\s,-+*/\.]*\]$
in both instances saying that there was an improper range inside the regex. I input both into online regular expression checkers (there's a million, like https://regex101.com/ and http://regexr.com/ ) and they all said the same thing:
- the
:-+
range in the "numeric_array" regex is backwards; the:
char is greater than+
- the
,-+
range in the "bracketed_strings" regex is backwards; the,
char is greater than+
I also hypothesized that "maybe MATLAB does regular expressions differently than everyone else", but could not find a shred of evidence that that's the case. Therefore,
What I think is happening is, MATLAB is throwing only a warning (or nothing at all) as it processes a malformed regular expression, perhaps processing it as what it thinks you want. Whereas "everyone else" (Octave, online regex checkers) are more loud/stringent about errors.
IIRC, reversing the ranges above seemed to fix the problem, but this'll need extensive testing...for the same reason that regular expression errors should be treated seriously.