Regular Expressions
Regular expression is a set of characters, called as the pattern, which helps in finding substrings in a given string. The pattern is used to detect the substrings
For example, suppose you have a dataset of customer reviews about your restaurant. Say, you want to extract the emojis from the reviews because they are a good predictor of the sentiment of the review.
Take another example, the artificial assistants such as Siri, Google Now use information retrieval to give you better results. When you ask them for any query or ask them to search for something interesting on the screen, they look for common patterns such as emails, phone numbers, place names, date and time and so on. This is because then the assitant can automatically make a booking or ask you to call the resturant to make a booking.
Regular expressions are very powerful tool in text processing. It will help you to clean and handle your text in a much better way.
Online tools where you can test your Regular Expressions
Learning Resource
https://pycon2016.regex.training/cheat-sheet - Cheat Sheet
Let's import the regular expression library in python.
import re
Let's do a quick search using a pattern.
re.search('Ravi', 'Ravi is an exceptional student! Ravi is Brilliant')
<_sre.SRE_Match object; span=(0, 4), match='Ravi'>