Created
October 21, 2014 14:11
-
-
Save z2s8/1473d68210459fb9c158 to your computer and use it in GitHub Desktop.
re4lm
This file contains 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
u0_a200@grouper:/ $ python | |
Python 3.2.2 (default, Jun 23 2014, 00:13:13) | |
[GCC 4.8] on linux-armv7l | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import re | |
>>> re.match('^[a-z0-9]{8}$', '878h76t5') | |
<_sre.SRE_Match object at 0x405ec480> | |
>>> re.match('^[a-z0-9]{8}$', '8786h76t5') | |
>>> re.match('^[a-z0-9]{8}$', '8786h76X5') | |
>>> s='ide az input' | |
>>> if re.match('^[a-z0-9]{8}$', s) != None: print(True) | |
... | |
>>> | |
>>> s='6g5f4d3s' | |
>>> if re.match('^[a-z0-9]{8}$', s) != None: print(True) | |
... | |
True | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
^[a-z0-9]{8}$ explained:
Also note that
^
and$
are necessary, because otherwise it would match '82838383838' too, as it contains our pattern.