Udemy

What is a Regular Expression?

A free video tutorial from Jazeb Akram
Data Scientist
Rating: 4.3 out of 5Instructor rating
11 courses
78,047 students
What is Regular Expression

Lecture description

Before Starting this course lets find out basic information about Regular Expressions.  So,

What is Regular Expressions?

Actually regular expressions are the pattern of special characters and symbol that we use to match strings, or you can call text in our search. It's also called Regex and RegexP. Regular expressions allow you to perform complex pattern matching on text. A small regular expression can replace the need for a large amount of code.So instead of writing a large amount of code, which could let you match the text you can simply write 1 line of regular expression by using symbols and special characters which could do the same amount of work as the large amount of code block.

Apart from that this video will answer the following questions.

  1. Regular Expression easy and real world example.

  2. What we can do with Regular Expressions?

  3. Regular Expressions Benefits? 

Learn more from the full course

The Complete Regular Expressions Course with Exercises

Learn All Regular Expressions for PHP Javascript Python Java Ruby Perl and Unix systems with exercises from scratch.

05:22:53 of on-demand video • Updated June 2023

Easily work with Complete Syntax of Regular Expressions
Have better understanding of Regex topics.
Create easy and complex regular expressions
Work with any supported Regexp Engine
Increase code Optimization
Proudly stand in Market
English
Hello welcome to this regular expressions course. My name is just a Jazeb Akram and I'll be your instructor throughout this course. Now before we start learning about Regular Expressions we should know why. It's one of the best approach to handle text through regular expressions. Actually regular expressions are the pattern of special characters and symbol that we use to match strings. Or you can call text in our search. It's also called Regex and RegexP. Regular expressions allow you to perform complex pattern matching on text. A small regular expression can replace the need for a large amount of code. So instead of writing a large amount of code, which could let you match the text you can simply write 1 line of regular expression by using symbols and special characters which could do the same amount of work as the large amount of code block. Now let me show you how the Regular Expressions actually work by a real world example. Now I'm on google and I typed Regular Expressions as a search string. Now you can see that this is the Wikipedia link so I'm going to click on this one. Now here is all the information about regular expression on Wikipedia.org But I wasn't intend to show you this text. What I was really interested in, how Regular Expression works. So I'm going to press Control+F to activate the search diagonal in chrome browser. Now you can see the field right here in which I can search for any special text. So for example, first if I search something like.. technical Now you can see that we got total 2 results and 1 of 2 results is just highlighted right here. Now, If I enter it again, now you can see that the next 'technical' is highlighted and we got only 2 results In-case if I search something different like 'computer sciences' you can see that I don't have any expression in this web page that match with 'computer sciences'. Now if I remove the 'S' at the end. And now you can see that we found 7 matches on this page and 1 of 7 is highlighted right here. Now if I enter one more time and enter key Now I'm on my second 'computer science' text, third fourth, fifth, sixth, and seventh. Now starting it again. So all the research what I'm doing right now is very comprehensive. This diagonal is only highlighting those word which could actually meet my requirement and my requirement was 'computer science' just the 'computer science'. So you can think this text which I put right here as a Regular Expression and all other text in which we are searching. You can think all of this text as a test string. So Regular Expressions are very powerful and they will only give you those results exactly what you searched for. Regular expressions are very powerful and they are kind of fun if you understand them. So at the end of this course you will be fully able to work with regular expression no matter how easy and complex regular expression you want to create. But you have to remember one thing regular expression is not a programming language like C , C++ , PHP, Pearl or Ruby. They are just the symbols. Or you can say characters which we arrange in certain orders that help us to match the text and they are very useful. For example you can match any text by using regular expression I just showed you an example on the Wikipedia website. And also you can search for something in a large amount of text file that you have in your computer. You can also find some text and replace it with the new one. You can pick text from one place and move it to another and you can also reuse your regular expression which you created before. The best feature in regular expression is validation. You can do any type of validation which you want. You can restrict your user to enter those name which could only have alphabets or spaces not the numbers. You can also restrict your use or not to add negative age and age is equal to zero. In verb forms, when you have to collect some information from the user. You can check whether your user is entering correct web address URL or not. by using Regular Expression. And you can also restrict the text in the comment section on your web forms so that the user could not enter certain words while commenting on your post. Furthermore, you can also check whether the e-mail the user has entered is valid or not. So the regular expression for email will look like something like this. Don't have to worry at all because this is just the introductory lecture. We will create all the regular expression throughout this course. Anyways, this Regular Expression for e-mail. will let the user with the e-mail example123@example.com to be correct one. This Regular Expression will also correct e-mail example_good@example.com.us But the same regular expression will not allow example123@example.com@us Because no email can have 2 @ signs in email. Whenever I learn a new skill I concoct elaborate fantasy scenarios where it helps me understand the skill So here's one for you. Someone killed a girl :/ And these two guys are talking about the murderer One is saying : "oh no! the killer must have followed her on vacation, but to find them, we would have to search through 200 MBs of e-mail looking for something formatted like an address". The Other one is saying: "it's hopeless..." because finding something in 200 MBs of e-mail will be difficult Now here someone is coming. "Everybody stand back!!". "I know regular expressions". So this guy you can call him 'Tarzan' or 'Spiderman' is coming towards them. Tap tap some regular expression on the computer. Find the murderer and flew away. And these two guys still don't know what happens here. So be like a Tarzan be like Spiderman. Use regular expression to find text exactly what you want. I'm not a big fan of Spider-Man so you can call him Tarzan. So now you know how important regular expressions are. So we are going to explore it further. So see you in the next lecture.