Created
December 11, 2018 10:32
-
-
Save kinow/d5ecac8f0ebcaa67b2e3c08ead92cf0f to your computer and use it in GitHub Desktop.
test_regex.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import re | |
p = re.compile(r"\d", re.UNICODE) | |
number_one = "1" | |
also_number_one = u"߁" | |
not_a_number = "test" | |
assert p.match(number_one) | |
assert p.match(also_number_one) | |
# only here it won't match | |
assert not p.match(not_a_number) | |
print("All good!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/890686/should-i-use-d-or-0-9-to-match-digits-in-a-perl-regex