pombreda / lepl

Automatically exported from code.google.com/p/lepl
Other
0 stars 0 forks source link

Regexp Inverted Ranges Unreliable #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A regexp that uses an inverted range (square brackets starting with a
caret) will give misleading results.  For example [^9-0] may match all digits.

The problem is that the parser for a regexp does not order the character
intervals before sending them to alphabet.invert.  This can be fixed by
changing the definition of "invert" in make_str_parser (lepl.regexp.str) to

  invert = lambda x: alphabet.invert(Character(x, alphabet))

since Character() does sort the intervals.

The next release of LEPL (2.4) will include this fix.

Andrew

Original issue reported on code.google.com by acooke....@gmail.com on 19 Apr 2009 at 2:32

GoogleCodeExporter commented 9 years ago

Original comment by acooke....@gmail.com on 3 May 2009 at 10:36