-
Notifications
You must be signed in to change notification settings - Fork 0
/
regex_match.py
36 lines (22 loc) · 862 Bytes
/
regex_match.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import re
# re.match(pattern, string, flags=0)
# line = "Cats are smarter than dogs"
# matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I)
# if matchObj:
# print "matchObj.group() : ", matchObj.group()
# print "matchObj.group(1) : ", matchObj.group(1)
# print "matchObj.group(2) : ", matchObj.group(2)
# else:
# print "No match!!"
text = """XF is not a bid for revolution, but a wager on the long game of history, demanding imagination, dexterity and persistence."""
# # matchRe = re.match( r'(.*) are (.*?) .*', text, re.M|re.I)
# matchRe = re.match( r',{2,}', text, re.M|re.I)
# if matchRe:
# print "matchRE::::", matchRE.group()
# else:
# print "No match !!"
# line.partition(keyword)
# text = 'Allowed Hello Hollow'
# for m in re.finditer('ll', text):
# print('ll found', m.start(), m.end())
print text.count(',')