8: Regular Expressions Flashcards

1
Q

regular expressions

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

regexes

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

re

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

docs.python.org/3/library/re.html

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

re.search(pattern, string, flags=0)

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

.

A

any character except a newline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

*

A

0 or more repetitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

+

A

1 or more repetitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

?

A

0 or 1 repetition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

{m}

A

m repetitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

{m, n}

A

m-n repetitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A

matches the start of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

$

A

matches the end of the string or just before the newline at the end of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

[ ]

A

set of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

[ ^ ]

A

complementing the set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

23
Q

re:MULTILINE

24
Q

re.DOTALL

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)