- [Instructor] Welcome to the next video of section four,
Parsing Email Addresses and URLs from Text.
In the previous video, we learned how to
print lines in reverse order.
In this video, we'll learn how to parse
email addresses from a contact list of an email client,
which is composed of many unwanted characters and words,
or from an HTML webpage.
Parsing a required text from a given file
is a common task that we encounter in text processing.
Items such as emails and URLs can be found out
with the help of correct regex sequences.
The regular expression pattern to match
an email address is as follows.
For example.
As we are using an extended regular expression,
plus for instance, we should use egrep.
The egrep regex pattern for an HTTP URL is as follows.
For example.
Let's see how it works.
The regular expressions are really easy design part by part.
In the email regex, we all know that an email address
takes the form of name at domain dot
some two to four letters.
Here, the same is written in the regex language as follows.
This means that some combination of characters
in the square block should appear one or more times,
that is the meaning of plus,
before a literal at the rate character appears.
Then, it should appear one or more times plus.
The pattern slash dot means
that a literal period should appear,
and finally, the last part should be
two to four alphabetic characters.
The case of an HTTP URL is similar to an email,
but we don't the need the name at match part
of the email regex.
Awesome.
We've successfully learned about parsing email addresses
and URLs from a text.
In the next video, we'll learn how to remove a sentence
in a file containing a word.