Suggestion for matching spaces in regular expressions
Mark-L6n opened this issue · 1 comments
Looking at regular expressions in the source code, I see the following for optional spaces: r' *'
.
An issue for using a space character instead of a character class for matching spaces is that there are a variety of code points used for spaces in UTF8/Unicode, see https://www.compart.com/en/unicode/category/Zs
To make this more robust, the re
module provides the character class \s
for spaces, but this also includes the character codes for carriage returns.
The regex
module provides a \h
character class, "horizontal spaces", which solves this problem, for ex regex.search(r'^\h*...', str)
In my experience, regex
has otherwise performed the same as re
, not requiring any code changes.
I'd like to keep mistune dependency free.