teaching.rouxl.es
egg
in text)Specified:
Pattern | Description |
---|---|
[abc] |
Matches either a, b, or c |
[a-z] |
Matches anything from lowercase a to lowercase z |
[^a-z] |
Matches anything that isn't from lowercase a to lowercase z |
[0-9] |
Matches any (single) digit |
[a-zA-Z123] |
Matches any lowercase or uppercase character, or the digits 1, 2, or 3 |
Predefined character classes
Pattern | Equivalent |
---|---|
\w |
[A-Za-z0-9_] |
\d |
[0-9] |
\s |
(Matches any 'whitespace' character) |
. |
Matches everything except for newlines. |
AB
- Matches A, then B (both are required)A[xt]e
Matches A, then either x or t, then E
|
is the separator used to match 'or'
A|B
- Matches either A or BQuantifier | Description |
---|---|
? |
0 or 1 (kind of like a question - is it there or not?) |
* |
0 or more |
+ |
1 or more |
{a} |
Match exactly a times (number) |
{a,} |
Match from a to infinity number of times |
{0,b} |
Match from 0 to b number of times |
{a,b} |
Match between a and b number of times |
(Ha)+
and Ha+
do different things!Anchor | Description |
---|---|
^ |
Matches the beginning of the string |
$ |
Matches the end of a string |
\b |
Matches a word boundary |
Some characters cannot be written directly because they have special roles in RegEx
\[](){}+*?|$^.
-
The quick brown fox jumped over the lazy dog\.
\n
, or \t
). What r-strings do in this case is that they automatically escape the backslashes for these special characters, so they look like real backslashes rather than what Python designates for those characters.r"<insert string here>"
- the r
at the front makes a string an r-string
links.rouxl.es/disc
)links.rouxl.es/feedback
Thanks for coming!
Please give me feedback on what to improve!