forked from meizhitu/100programhomework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path100-32-literal-17.py
31 lines (27 loc) · 896 Bytes
/
100-32-literal-17.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
__author__ = 'rui'
#coding=utf-8
import re
def regexTest(pattern, input):
#re.IGNORECASE|re.MULTILINE|re.LOCALE|re.UNICODE|re.DOTALL|re.VERBOSE
regex = re.compile(pattern, re.DOTALL)
m = regex.search(input)
if m:
print("search: ")
print(m.groups())
else:
print('search: not match')
m = regex.match(input)
if m:
print("match: ")
print(m.groups())
else:
print('match: not match')
m = regex.findall(input)
if m:
print("findall: ")
print(m)
else:
print('findall: not match')
if __name__ == '__main__':
regexTest("(\w+)", "Regex Query Tool – A tool that allows the user to enter a text string and then in a separate control enter a regex pattern. It will run the regular expression against the source text and return any matches or flag errors in the regular expression.\
")