grep: Regular Expressions
3 Regular Expressions
*********************
A “regular expression” is a pattern that describes a set of strings.
Regular expressions are constructed analogously to arithmetic
expressions, by using various operators to combine smaller expressions.
‘grep’ understands three different versions of regular expression
syntax: basic (BRE), extended (ERE), and Perl-compatible (PCRE). In GNU
‘grep’, basic and extended regular expressions are merely different
notations for the same pattern-matching functionality. In other
implementations, basic regular expressions are ordinarily less powerful
than extended, though occasionally it is the other way around. The
following description applies to extended regular expressions;
differences for basic regular expressions are summarized afterwards.
Perl-compatible regular expressions have different functionality, and
are documented in the pcre2syntax(3) and pcre2pattern(3) manual pages,
but work only if PCRE is available in the system.
Menu