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.


Next topic: Regular expression grouping
Previous topic: Editor regular expressions

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005