QUERY · ISSUE
ure: character classes not working in sets
enhancementextmod
All of these assert statements fail, but I don't think they should:
import ure
assert ure.match('[\\w]', "a") is not None
assert ure.match('[\\s]', " ") is not None
assert ure.match('[\\d]', "1") is not None
assert ure.match('[\\w.]*$', "boot.py") is not None
CANDIDATE · ISSUE
ure: escaped characters inside character classes not working
extmod
This is similar and related to https://github.com/micropython/micropython/issues/3178
As per the above issue
>>> import ure
>>> print( ure.search(r"[a\-z]", "-") )
None
>>> print( ure.search(r"[a\-z]", "f") )
<match num=1>
escaping '-' inside character classes doesn't work, it still treats it as a range specifier. There is the workaround for that issue though by putting - at the start/end of the character class.
Similarly though, escaping ] also doesn't work, it appears to close the character class, but then there's the extra ] later on so you end up with an invalid regex.
>>> import ure
>>> print( ure.search(r"[a\]z]", "a") )
None
I don't think there's any way to make a character class that matches ']` at all.