[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3. Regular Expressions
A regular expression, or regexp, is a way of describing a
set of strings.
Because regular expressions are such a fundamental part of awk
programming, their format and use deserve a separate chapter.
A regular expression enclosed in slashes (‘/’)
is an awk
pattern that matches every input record whose text
belongs to that set.
The simplest regular expression is a sequence of letters, numbers, or
both. Such a regexp matches any string that contains that sequence.
Thus, the regexp ‘foo’ matches any string containing ‘foo’.
Therefore, the pattern /foo/
matches any input record containing
the three characters ‘foo’ anywhere in the record. Other
kinds of regexps let you specify more complicated classes of strings.
Initially, the examples in this chapter are simple. As we explain more about how regular expressions work, we present more complicated instances.
3.1 How to Use Regular Expressions | ||
3.2 Escape Sequences | How to write nonprinting characters. | |
3.3 Regular Expression Operators | ||
3.4 Using Bracket Expressions | What can go between ‘[...]’. | |
3.5 gawk -Specific Regexp Operators | Operators specific to GNU software. | |
3.6 Case Sensitivity in Matching | How to do case-insensitive matching. | |
3.7 How Much Text Matches? | How much text matches. | |
3.8 Using Dynamic Regexps |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |