Regular Expressions
This document provides a brief description of the syntax of regular
expressions.
- A list of characters enclosed by [ and ]
matches any character in the list.
- A list of characters enclosed by [ and ]
with ^ as the first character
matches any character not in the list.
- A range of characters can be expressed by
separating the first and last characters
in the range by a hyphen and enclosing them by [ and ].
- A period (.) matches any single character.
- A regular expression matching a single
character (i.e. not a range) can be followed by a repetition operator:
- ? indicates that the preceding item is optional,
matched once at most.
- * indicates that the preceding item will be
matched zero or more times.
- + indicates that the preceding item will be
matched one or more times.
- {n} indicates that the preceding item is
matched exactly n times.
- {n,} indicates that the preceding item is
matched n or more times.
- {,m} indicates that the preceding item is
optional and is matched m times at most.
- {n,m} indicates that the preceding item is
matched at least n times, but no more than m times.
[UNIX Survival home page]