Change language

# 4 Introduction to Python RegEx | Python Advanced Tutorial

# 4 Introduction to Python RegEx | Python Advanced Tutorial

in this video you will be learning about python Regex RegEx is a shortform for regular expression.

quickly take a look at the agenda for today.

what are regular expressions? how can we define a regular expression? regular expressions are essentially and highly specialized programming language these regular expression are used with the most of the programming languages these are formal languages, they dont contain instruction set they contain a special text string describing pattern.

if you want t use these regular expression in programming we need to make use of re module.

lets see why we use regular expression? regular expression are used to filter text assume, you have a string you need to filter some of the text from that string.

in that case you can go for regular expression.

regular expression allow us to find pattern, selective replacement.

you will understand this when we take aplication next topic is application of regular expression where excatly we are using these regular expression. ex: consider you have a list of names you need to extract only those names whose last name patil, how you can do that? using regular expression, you can define a pattern , so what pattern you need to define ? since i want names with patil i can define pattern as patil.

match this pattern with the name list.

i can get all names whose last name is patil.

next application, i.e email validation or domain verification if you want to verify gmail address you just need to define a pattern and match with the pattern so that you can filter out the fake ids i hope you are clear.

if you need to verify the correct number of digits in credit or debit cards.

your credit card is having 16 numbers some manufacturing defect if your credit card comes with only 10 digits then it is a invalid credit card.

let us consider you are working with files you might be having hundreds and thousands of files in your folder.

you want only those files whose name sequence starts with678 and also the file extension is .pdf, so you dont want all other files you can easily do this by using regular expression.

you need to define again a pattern dont worry you will be learning how to define these patterns when we take programming examples.

this is just introduction video consider you are having a text file you want to replace some instances of this file i want to replace cockroach and spider i can replace it using regular expression, and replace with the new word.

you can make use this you can make use this regular expression in data extracting, phone number validations, all the phone number will be having country code if you want to verify those codes, you can make use of this regular expression.

web scraping applications.

web scraping is collecting data from websites i hope now you have basic idea of what are regular expression why we need these regular expression these regular expression are nothing but simple text string called, pattern which user can use to verify data, extract data, or replace data.


Learn programming in R: courses


Best Python online courses for 2022


Best laptop for Fortnite


Best laptop for Excel


Best laptop for Solidworks


Best laptop for Roblox


Best computer for crypto mining


Best laptop for Sims 4


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers



Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method