forked from iliyahoo/Automate-The-Boring-Stuff-With-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_regex_170.txt
More file actions
22 lines (22 loc) · 742 Bytes
/
ex_regex_170.txt
File metadata and controls
22 lines (22 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
+re.compile()
+no need to use escape before brackets and parenthesis
-groups
-re.findall(regex_object, string)
+0: whole corresponded string; 1 - 111 ; 2 - 222-2222
+backslash
+list of tuples
+or
+preceding character repeats 0 or 1 times; non-gredy
+ {1,} ; * {0,}
+exactly 3 times; from 3 up to 5 times
+\d - digital; \w - alphanum ; \s - whitespace
+negative
+append , re.IGNORECASE
+any character except new-line ; across multiple lines
+gready and non-gready
+[0-9a-z]
+X drummers, X pipers, five rings, X hens
+use comments and new-lines on compile
+re.compile(r'^(\d{1,3}(?:,\d{3})*)$', re.MULTILINE)
+re.compile(r'((?:[A-Z][a-z-]+\s){2})')
+re.compile(r'((?:Alice|Bob|Carol)\s(?:eats|pets|throws)\s(?:apples|cats|baseballs)\.)', re.I)