Https://docs.python.org/2/howto/regex.html
Identifiers:
\d any number
\d anything but a number
\s Space
\s anything but a space
\w any character
\w anything but a character
. Any character, except for a newline
\b The whitespace around words
\. A period
Modifiers:
{1,3} we ' re expecting 1-3
+ Match 1 or more
? Match 0 or 1
* Match 0 or more
$ match the end of a string
^ Matching the beginning of a string
| Either or
[] Range or "variance" [a-za-z1-5]
{x} expecting "X" Amount
White Space characters:
\ n New Line
\s Space
\ t tab
\e Escape
\f Form Feed
\ r return
DONT forget!:
. + * ? { } $ ^ ( ) { } | \
Need to escape them
Method/attribute |
Purpose |
Match () |
Determine if the RE matches at the beginning of the string. |
Search () |
Scan through a string, looking for all location where this RE matches. |
FindAll () |
Find all substrings where the RE matches, and returns them as a list. |
Finditer () |
Find all substrings where the RE matches, and returns them as aniterator. |
Method/attribute |
Purpose |
group () |
return the string matched by the re |
start () |
|
end () |
|
span () |
return a tuple containing the (start, End) positions of the match |
Regular Ex Notes