Regular Expression Patterns
Categories: Python
Except for control characters, (+ ? . * ^ $ ( ) [ ] { } | \), all characters match themselves. You can escape a control character by preceding it with a backslash.
Following table lists the regular expression syntax that is available in Python −
Sr.No.Pattern & Description
1. ^ - Matches beginning of line.
2. $ - Matches end of line.
3 - Matches any single character except newline. Using m option allows it to match newline as well.
4. [...] - Matches any single character in brackets.
5. [^...] - Matches any single character not in brackets
6. re* - Matches 0 or more occurrences of preceding expression.
7. re+ - Matches 1 or more occurrence of preceding expression.
8. re? - Matches 0 or 1 occurrence of preceding expression.
9. re{ n} - Matches exactly n number of occurrences of preceding expression.
10. re{ n,} - Matches n or more occurrences of preceding expression.