8: Regular Expressions Flashcards
1
Q
regular expressions
A
2
Q
regexes
A
3
Q
re
A
4
Q
docs.python.org/3/library/re.html
A
5
Q
re.search(pattern, string, flags=0)
A
6
Q
.
A
any character except a newline
7
Q
*
A
0 or more repetitions
8
Q
+
A
1 or more repetitions
9
Q
?
A
0 or 1 repetition
10
Q
{m}
A
m repetitions
11
Q
{m, n}
A
m-n repetitions
12
Q
A
matches the start of the string
13
Q
$
A
matches the end of the string or just before the newline at the end of the string
14
Q
[ ]
A
set of characters
15
Q
[ ^ ]
A
complementing the set
16
Q
\d
A
decimal digit
17
Q
\D
A
not a decimal digit
18
Q
\s
A
whitespace characters
19
Q
\S
A
not a whitespace character
20
Q
\w
A
word character … as well as numbers and the underscore
21
Q
\W
A
not a word character
22
Q
re.IGNORECASE
A
23
Q
re:MULTILINE
A
24
Q
re.DOTALL
A
25
^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~--]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0, 61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$
26
re.match(pattern, string, flags=0)
27
re.fullmatch(pattern, string, flags=0)
28
A|B
either A or B
29
(...)
a group
30
(?:...)
non-capturing version
31
: =
32
re.sub(pattern, repl, string, count=0, flags=0)
33
re.split(pattern, string, maxsplit=0, flags=0)
34
re.findall(pattern, string, flags=0)