Regular Expression Examples

operator description sample pattern matches doesn't match
. any character but newline . e \n
^ beginning of string ^a apple banana
$ end of string a$ banana apple
[characters] any characters in braces [abcABC] a d
[char range] describe range of characters [a-zA-z] r 9
\d any digit \d\d\d-\d\d\d\d 123-4567 the-thing
\b word boundary \bthe\b the theater
+ one or more occurrences of preceding character \d+ 1234 text
* zero or more occurrences of preceding character [a-zA-z]\d* f16, b 9
{digit} repeat preceding character that many times \d{3}-\d{4} 123-4567 999-99-9999
| or operator apple|banana apple, banana peach
(pattern segment) store results in pattern memory returned with numeric code (^.).*/1 gig, blab
(any word that starts and ends w/ same letter)
any other word