10000 ure: escaped characters inside character classes not working · Issue #5220 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
ure: escaped characters inside character classes not working #5220
Closed
@andrewleech

Description

@andrewleech

This is similar and related to #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    extmodRelates to extmod/ directory in source

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0