Introduction to Python RegEx

Regular Expression (or it can be called  as Regex or RE), is a special type of string that can be used for matching terms or words inside a string. As the name suggests it is an expression which contains a sequence of characters that define a search pattern.

A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are used in UNIX world and different programming languages.

It is widely used in projects that involve text validation, natural language processing, web applications that require validating string input (like email address) and pretty much most data science projects that involve text mining.

The Python module re provides full support for Perl-like regular expressions in Python. The re module raises the exception re.error if an error occurs while compiling or using a regular expression.

We would cover several important functions, which would be used to handle regular expressions. But a small thing first: There are various characters, which would have special meaning when they are used in regular expression. To avoid any confusion while dealing with regular expressions, we would use Raw Strings as r'expression'.