Ubuntu‎ > ‎

Regular Expressions

\d any number
\D anything but a number
\s any space
\S anything but a space
\w any character
\W anything but a character
. any character except a line break
\b a space which precedes or follows a whole word ex. My Space
+ one or more of the code that precedes it
? zero or one repetitions of the code that precedes it
* zero or more repetitions of the code that precedes it
{n} expect n of the code that precedes it to be in the code
\d{5} expect 5 of the digits in a row
\d{1,5} expect 1-5 digits in a row
\b any space preceding or following a whole word
\B when there is no space separating characters
^ reference the beginning of a line of text
Some characters like $ . ( ) * + ? [ \ | require escaping which is the \
Others requiring escape:
\e Escape
\f Form Feed
\n Newline
\r Carriage Return
\t Horizontal tab
$ end of a sentence

Search for Jennifer: Jennifer\s\w+\s
\$\d*\.\d{2} would match $100.00
Search for commonly misspelled words: Calender Calendar calend[ae]r
Search for every single lower case letter: [a-z]
Search for all numbers: [0-9]
Search for all capital letters from A-F and all lower letters from a-t and all numbers 0-4: [A-Fa-t0-4]
Search for all sentences beginning with Cat: '(^Cat\s.+$)'