Created
August 23, 2017 15:45
-
-
Save abhinavkorpal/69405e166ea1e4e31d30d9fdf259db3c to your computer and use it in GitHub Desktop.
Python Regular Expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ Used to drop the special meaning of character | |
following it (discussed below) | |
[] Represent a character class | |
^ Matches the beginning | |
$ Matches the end | |
. Matches any character except newline | |
? Matches zero or one occurrence. | |
| Means OR (Matches with any of the characters | |
separated by it. | |
* Any number of occurrences (including 0 occurrences) | |
+ One ore more occurrences | |
{} Indicate number of occurrences of a preceding RE | |
to match. | |
() Enclose a group of REs | |
\d Matches any decimal digit, this is equivalent | |
to the set class [0-9]. | |
\D Matches any non-digit character. | |
\s Matches any whitespace character. | |
\S Matches any non-whitespace character | |
\w Matches any alphanumeric character, this is | |
equivalent to the class [a-zA-Z0-9_]. | |
\W Matches any non-alphanumeric character. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment