In: Computer Science
2. Write a Regular expression that matches words, where a word is a series of ASCII alphabetic characters. Match both upper- and lowercase.
Note: Enter man grep to read about the options
of grep.
Answer:
Answer:
grep '[A-Za-z]*' sun.txt
Justification:
grep is the command used to match a regular expression.
[A-Za-z] matches the uppercase or lowercase alphabet from the ASCII characters.
* matches zero or more occurrences of the preceding pattern (i,e. [A-Za-z]* matches zero or more occurrences of words that start with lowercase or the uppercase ASCII characters.)
sun.txt is a file that the grep command looks in to match the given pattern.
sun.txt
Output:
The words marked in red color are the words
matched by the regular expression given by us.