Skip to content
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

Not sure if this regex does what you want #62

Open
LouisMichael opened this issue Feb 19, 2019 · 1 comment
Open

Not sure if this regex does what you want #62

LouisMichael opened this issue Feb 19, 2019 · 1 comment

Comments

@LouisMichael
Copy link

I was looking over project regex and I noticed this one. It seems to try to look for punctuation and is trying to use \p{} for unicode but this is not a feature supported in python. It also might be dead code in general.

@davisjam
Copy link

Quick test:

$ cat t.py
import re

PUNCTUATION = re.compile("[^\\p{Ll}\\p{Lu}\\p{Lt}\\p{Lo}\\p{Nd}\\p{Pc}\\s]")
print("regex: " + PUNCTUATION.pattern)
for char in ["a", "p", "!"]:
	if PUNCTUATION.search(char):
		print("Matches a '{}'".format(char))
	else:
		print("Does not match a '{}'".format(char))

$ python3 t.py
regex: [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}\s]
Matches a 'a'
Does not match a 'p'
Matches a '!'

It matches "a" but not "p" because the character class is looking for NOT "p { L l ...".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants