Regex Expression: |

Syntax: pattern1|pattern2

Search for both of them, if either is found it is true.


 re.findall("(the|top|coder)", "Marius is one of the topcoders.")
['the', 'top', 'coder']

Regex Expression: ^

Syntax: ^pattern

This would return True only if pattern is at the starting of the given text.


re.findall("^http", "")

Regex Expression: $

Syntax: pattern$

Returns True if pattern is in the end of given text


 re.findall("in$", "")

Regular Expression: .

Syntax: pattern.

Use to match a single character.

 >>> re.findall("htt.", "")

>>> re.findall("ht..", "")

Regular Expression: { }

Syntax: Pattern{number of times pattern must repeat continuously}

It multiplies the pattern number of times given within the braces and then search for it in the given text. In the following example it multiplies ‘t’ twice thus pattern to be searched is ‘tt’


>>>re.findall("t{2}", "")

Regular Expression: { ,}

Syntax: Pattern{n,}

Matches n or more occurrences of preceding expression.


>>> re.findall("t{2}", ""

Basics of Regular Expressions in Python