RegEx Flashcards
1
Q
$
A
Ends with
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
3
Q
\s and \S
A
\s whitespace
\S non-whitespace
4
Q
*
A
Repeat zero or more times
5
Q
*?
A
Repeat zero or more time – non-greedy
6
Q
+
A
Repeat one or more times
7
Q
+?
A
Repeat one or more times – non-greedy
8
Q
[ ]
Definition
Possibilities
A
Listed set.
Can contain a range
9
Q
How to code “not in this set of chars”?
A
[^xyz]
10
Q
How to set a range?
A
[a-z]
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)