DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Regular expressions

Escaping metacharacters

The special meaning of some metacharacters is dependent on their position in the regular expression, for example the start and end of line indicators. However, most metacharacters retain their special meaning irrespective of location. How then can they used as literal characters?

In such cases, the backslash (\) is used is used to ``escape'' the special meaning of the character that follows it. For example, \$ matches the ``$'' symbol rather than the end of a line. For example:

Summer sale now on\. Save $$\$

The backslash is used to quote the period and the final dollar sign (the other dollar signs are position-sensitive, and have no special meaning).

Because the backslash itself may be required to have only its literal meaning, \\ matches ``\'': the first backslash removes the special meaning from the second.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004