4 ms·
If you need to detect syntax issues, you can use `re.compile()`. For example, before Python 3.11, you'll get an error: >>> re.compile(r'\w++') re.error
by asicsp 2y ago
If you need to detect syntax issues, you can use `re.compile()`. For example, before Python 3.11, you'll get an error:
>>> re.compile(r'\w++')
re.error: multiple repeat at position 3
To use such a compiled pattern, you can call the method on this object instead of `re`. For example:
>>> word = re.compile(r'\w+')
>>> word.findall('hello-there!')
['hello', 'there']
- hombre_fatal 2y agoThe existent of re.compile is compatible with and doesn’t address their complaint.