Beispiel #1
0
from findMatch import find_match

#optionl a-z. char, optional 0-9, end
find_match('^[a-z]?.[0-9]?$', '', 1)  # N
find_match('^[a-z]?.[0-9]?$', 'a', 1)  # Y
find_match('^[a-z]?.[0-9]?$', 'aa', 1)  # Y
find_match('^[a-z]?.[0-9]?$', 'aa5', 1)  # Y
find_match('^[a-z]?.[0-9]?$', 'aa55', 1)  # N
Beispiel #2
0
from findMatch import find_match

#starts with a, then optional b, then c ends the string
find_match('^ab*c$', 'ac', 1)  # Y
find_match('^ab*c$', 'abc', 2)  # Y
find_match('^ab*c$', 'abbbbc', 3)  # Y
find_match('^ab*c$', 'ababc', 4)  # N
Beispiel #3
0
from findMatch import find_match

#optionl a-z. char, optional 0-9, end
find_match('^[a-z]{2}$', '', 1)  # N
find_match('^[a-z]{2}$', 'a', 2)  # N
find_match('^[a-z]{2}$', 'aa', 3)  # Y
find_match('^[a-z]{2}$', 'aaa', 4)  # N
Beispiel #4
0
#slide 5
from findMatch import find_match

#\s - white space
#\S - not white space
find_match(r'\s$', ' ', 1)  # Y
find_match(r'\s$', 'a', 2)  # N
find_match(r'\S$', ' ', 3)  # N
find_match(r'\S$', 'a', 4)  # Y
Beispiel #5
0
#slide 5
from findMatch import find_match

#\d - is the same as [0-9]
#\D - is the same as [^0-9]
find_match(r'\d$', '1', 1)  # Y
find_match(r'\d$', 'a', 2)  # N
find_match(r'\D$', '1', 3)  # N
find_match(r'\D$', 'a', 4)  # Y
Beispiel #6
0
#slide 5
from findMatch import find_match

#\w is the same as [a-zA-Z0-9_]
#\W is the same as [^a-zA-Z0-9_]
find_match(r'\w$', 'a', 1)  # Y
find_match(r'\w$', '?', 2)  # N

find_match(r'\W$', 'a', 3)  # N
find_match(r'\W$', '?', 4)  # Y
Beispiel #7
0
from findMatch import find_match

#at least 2 characters
find_match('^[a-z]{2,}$', '', 1)  # N
find_match('^[a-z]{2,}$', 'a', 1)  # N
find_match('^[a-z]{2,}$', 'aa', 1)  # Y
find_match('^[a-z]{2,}$', 'aaa', 1)  # Y
Beispiel #8
0
#slide 5
from findMatch import find_match

#\w is the same as [a-zA-Z0-9_]
find_match(r'\w{5}$', 'a1A_v', 1)  # Y
find_match(r'\w{5}$', 'a1A?v', 2)  # N
find_match(r'\w{5}$', 'a1A_', 3)  # N
Beispiel #9
0
from findMatch import find_match

#starts with a, then optional b, then c ends the string
find_match('^[A-Z]+', '', 1)  # N
find_match('^[A-Z]+', 'c', 1)  # N
find_match('^[A-Z]+', 'A', 1)  # Y
find_match('^[A-Z]+', 'ABBFAb', 1)  # Y
Beispiel #10
0
from findMatch import find_match

find_match('^([A-Z][a-z]){2,}$', '', 1) # N
find_match('^([A-Z][a-z]){2,}$', 'Aa', 2) # N
find_match('^([A-Z][a-z]){2,}$', 'AaAa', 3) # Y
find_match('^([A-Z][a-z]){2,}$', 'AaAaAa', 4) # Y
find_match('^([A-Z][a-z]){2,}$', 'AAaa', 5) # N
find_match('^([A-Z][a-z]){2,}$', 'aa', 6) # N