File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ import re
2
+
3
+
4
+ def multi_re_find (patterns ,phrase ):
5
+
6
+ for pat in patterns :
7
+ print ("Searching for pattern: {}" .format (pat ))
8
+ print (re .findall (pat ,phrase ))
9
+ print ("\n " )
10
+
11
+
12
+ test_phrase = 'sdsd..sssddd..sdddsddd...dsds...dsssss...sdddd'
13
+ test_patterns = ['sd*' ] # this means zero or more ds
14
+ multi_re_find (test_patterns , test_phrase )
15
+ test_patterns = ['sd?' ] # this means zero or one ds
16
+ multi_re_find (test_patterns , test_phrase )
17
+ test_patterns = ['sd+' ] # this means one or more ds
18
+ multi_re_find (test_patterns , test_phrase )
19
+ test_patterns = ['sd{1,3}' ] # this means one to three ds
20
+ multi_re_find (test_patterns , test_phrase )
21
+
22
+ test_patterns = ['s[sd]+' ] # this means one or more either s or d
23
+ multi_re_find (test_patterns , test_phrase )
24
+
25
+
You can’t perform that action at this time.
0 commit comments