Skip to content

re module not matching [\s\S] and equivalents #8525

Closed
@michalpokusa

Description

@michalpokusa

CircuitPython version

Adafruit CircuitPython 8.2.4 on 2023-08-22; Adafruit Feather ESP32-S2 TFT with ESP32S2

Code/REPL

>>> import re
>>> re.search(r">\S*?<", ">test<") is None
False
>>> re.search(r">\s*?<", "> <") is None
False
>>> re.search(r">[\s\S]*?<", "> test <") is None
True
>>> re.compile(">.*?<", 16).search("> test <") is None
False

Behavior

When searching for \S aka any non-whitespace character, re module finds a match.
Similarly, when searching for \s aka any whitespace character, re module also finds a match.

But, when combining them together, creating a popular any character re module is unable to match.

This pattern is correct, and in theory should be possible to use in CircuitPython, as all the components (\s, \S, sets [], non-greedy *?) are supported.
image

Similar issue hapens when using \d and \D, \w and \W.

Using .compile() with re.DOTALL which is a literal 16, and with changed patterns ([\s\S] to .) seems to make it possible to match such strings, but still, the issue is present, it is just going around it.

Description

No response

Additional information

Possibly related, but maybe the cause is completely different: #6860

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions