Regular Expressions   «Prev 

Handling special cases in Regular Expressions

1) Using the cat command to display the sample file named text

2) The C shell interprets an ! as the command history character, even within quotes. This command uses bad syntax and produces an "Event not found" error.

3) To correct the previous command, use \! instead. Now the search succeeds.

4) This command is meant to search for the title Mr., but it actually finds Mr. followed by any character. The period (.) operates as a regular expression inside the quotes, and two lines match.

5) To search for a literal period, use \. . In the regular expression. Now the search finds just one matching line.

6) If a regular expression contains a single quote such as the word isn't
surround the expression with double quotes.

7) If you single-quote a regular expression that already contains a single quote, a syntax error occurs.

8) If a regular expression contains a double quote, as in the pattern "Hello" , surround the expression with single quotes. Because the is treated as a literal character, a matching is not needed. However, you need a matching pair of single quotes because they are used to enclose the argument

Ad Mastering Regular Expressions