My notepad

Chris' IT notes…
← Back

Regex - Grep reference

Regex operator Meaning
. Matches any single character.
? The preceding item is optional and will be matched, at most, once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{N} The preceding item is matched exactly N times.
{N,} The preceding item is matched N or more times.
{N,M} The preceding item is matched at least N times, but not more than M times.
- Represents the range if it's not first or last in a list or the ending point of a range in a list.
^ Matches the empty string at the beginning of a line; also represents the characters not in the range of a list.
$ Matches the empty string at the end of a line.
\b Matches the empty string at the edge of a word.
\B Matches the empty string provided it's not at the edge of a word.
< Match the empty string at the beginning of word.
> Match the empty string at the end of word.
(a b)
[abc] Range (a or b or c)
[^abc] NOT a or b or c
[a-z] Any letter (lowercase) from a to z
[A-Z] Any letter (uppercase) from a to z
[a-zA-Z] Any letter (upper and lowercase) from a to z
[0-9] Any digit from 0 to 9

A most exhaustive cheat sheet is available here