NLP Q#2: Write regular expressions for the following languages. By "word", we mean an alphabetic string separated from other words by whitespace, any relevant punctuation, line breaks, and so forth. 1. the set of all strings with two consecutive repeated words (e.g., "Humbert Humbert" and "the the" but not "the bug" or "the big bug"); 2. all strings that start at the beginning of the line with an integer and that end at the end of the line with a word; 3. all strings that have both the word grotto and the word raven in them (but not, e.g., words like grottos that merely contain the word grotto); 4. Demonstrate a pattern to check if the email address is valid. 5. Demonstrate a pattern to verify the validity of a phone number, and check if it belongs to the Pakistani Mobile Network.
NLP
Q#2:
Write regular expressions for the following languages. By "word", we mean
an alphabetic
string separated from other words by whitespace, any relevant punctuation, line breaks, and so
forth.
1.
the set of all strings with two consecutive repeated words (e.g., "Humbert Humbert" and
"the the" but not "the bug" or "the big bug");
2.
all strings that start at the beginning of the line with an integer and that end at the end of
the line with a word;
3.
all strings that have both the word grotto and the word raven in them (but not, e.g., words
like grottos that merely contain the word grotto);
4.
Demonstrate a pattern to check if the email address is valid.
5.
Demonstrate a pattern to verify the validity of a phone number, and check if it belongs to
the Pakistani Mobile Network.
6.
Demonstrate a RE to remove symbols and non-alphanumeric characters from the string
paragraph.
7.
Demonstrate a RE to remove URLs and HTML tags from the text string.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps