-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplify screws up literal special characters #28
Comments
Issue still exists 😞 Used version is exrex-0.10.5.
|
It seems that the issue is due to the following lines of elif i[0] == sre_parse.LITERAL:
ret += unichr(i[1]) The issue appears to be resolved, if we change these lines as follows: elif i[0] == sre_parse.LITERAL:
u = unichr(i[1])
ret += u if u not in sre_parse.SPECIAL_CHARS else '\\{0}'.format(u) After the change, I get: >>> import exrex
>>> exrex.simplify(r'\.')
'\\.'
>>> exrex.simplify('[.]')
'\\.'
>>> exrex.simplify('.')
'.'
>>> exrex.simplify(r'\$')
'\\$'
>>> exrex.simplify('[$]')
'\\$'
>>> exrex.simplify('[a]')
'a' I belive that |
@vwyu That does indeed appear to fix the issue. Do you want to make a pull request? |
I am also seeing this on 0.10.5 with |
simplify
turns a literal period into an unescaped period.EDIT: This affects any single special character.
The text was updated successfully, but these errors were encountered: