www.delorie.com/gnu/docs/regex/regex_7.html   search  
 
Buy the book!


Regex

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Common Operators

You compose regular expressions from operators. In the following sections, we describe the regular expression operators specified by POSIX; GNU also uses these. Most operators have more than one representation as characters. See section 2. Regular Expression Syntax, for what characters represent what operators under what circumstances.

For most operators that can be represented in two ways, one representation is a single character and the other is that character preceded by `\'. For example, either `(' or `\(' represents the open-group operator. Which one does depends on the setting of a syntax bit, in this case RE_NO_BK_PARENS. Why is this so? Historical reasons dictate some of the varying representations, while POSIX dictates others.

Finally, almost all characters lose any special meaning inside a list (see section 3.6 List Operators ([ ... ] and [^ ... ])).

3.1 The Match-self Operator (ordinary character)  Ordinary characters.
3.2 The Match-any-character Operator (.)  .
3.3 The Concatenation Operator  Juxtaposition.
3.4 Repetition Operators  * + ? {}
3.5 The Alternation Operator (| or \|)  |
3.6 List Operators ([ ... ] and [^ ... ])  [...] [^...]
3.7 Grouping Operators (( ... ) or \( ... \))  (...)
3.8 The Back-reference Operator (\digit)  \digit
3.9 Anchoring Operators  ^ $


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003