Regular expressions note
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Regex Note


Identifiers Meaning
\ escape character
\d any number
\D anything but a number
\s space
\S anything but a space
\w any letter
\W anything but a letter
\b space around whole words
. any character, except for a new line
\. period


Modifiers Meaning
? match 0 or 1
* match 0 or more
+ match 1 or more
$ match the end of a string
^ match the beginning of a string
| either or
[] range or variance e.g. [A-Z]
{x} expecting x amount
{x, y} expect to see this x-y amounts of the preceding code

White Space Characters

White Space Characters Meaning
\n new line
\s space
\t tab
\e escape
\f form feed
\r carriage return

Note: Don't forget to escape the following characters if used!
. + * ? [ ] $ ^ ( ) { } | \


  1. Regular Expressions with re Python Tutorial