DistributedNetworks DistributedNetworks


Regular Expressions   «Prev 

Handling special cases in regular expressions

Using the cat command to display the sample file named text

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.

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

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.

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

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

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

If a regular expression contains a double quote, as in the pattern "Hello" , surround the expression with single quotes.

Mastering Regular Expressions