Introduction

Hello coders! Let’s start our quest with regular expressions (RegEx). In Python, the module re provides full support for Perl-like regular expressions in Python. We need to remember that there are many characters in Python, which would have special meaning when they are used in regular expression. To avoid bugs while dealing with regular expressions, we use raw strings as r'expression'.

The re module in Python provides multiple methods to perform queries on an input string. Here are the most commonly used methods:

re.match()
re.search()
re.split()
re.sub()
re.findall()
re.compile()

We will look at these function and related flags with examples in the next section.

In case you do not know what’s this all about, it is a special sequence of characters or pattern that helps us to match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are widely used in the UNIX world. This course assumes that you have basic understanding of the REGEX patterns, if you don’t, not to worry, we’ll introduce with some REGEX basics in the next lesson!