RegEx Flashcards

1
Q

$

A

Ends with

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

Def
2 examples

A

Not.
Use as “at beginning of line”, i.e., no preceding chars
Use as not, e.g., [^foo] to match all non-foo chars

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

\s and \S

A

\s whitespace

\S non-whitespace

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

*

A

Repeat zero or more times

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

*?

A

Repeat zero or more time – non-greedy

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

+

A

Repeat one or more times

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

+?

A

Repeat one or more times – non-greedy

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

[ ]
Definition
Possibilities

A

Listed set.

Can contain a range

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

How to code “not in this set of chars”?

A

[^xyz]

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

How to set a range?

A

[a-z]

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

How to say “Grab everything relevant after char @ and up to but not including the next space char”?

A
y = "email@foo.com"
yprint = re.findall('@(\S+)', y)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly