You are on page 1of 3

Basic Regular Expression Notes

Syntax Meaning Example Matched DFS !Match


. Any single non-null character Sh.t Shot, Shut, etc.. - Sht, Shoot,
a This particular character alone a a
Any other character
than a
ab This particular characters tha. that, than, thal, thay Any other joined
joined alone character than ab
a|b Or demo|example demo, example c, ab, ba, aa

* Zero or more times go*gle gooooogle, gogle, ggle, gooogoogle


google

[abc] any of these single characters tha[nt] than, that tha, thant

[a-d] any of these single characters so[b-f] sob, soc, sod, soe, sof so, sobb, soy
in range

[^abc] none of these characters


(notice ^ leads off)
[^a-d] not a character within this so[^b-f] soa,sog, soh, sot, sos sob, soc, sod, soe,sof
range
(notice ^ leads off)
^ starts with ^The These, The, Theatre, these, Tomas, Darn
notice NOT within [grouping] Theta
$ string or ϵ ends with $ton cotton, Clinton, ton, jerk, certain,
Scraton, Easton
? Zero or one character (dos)?e dose, e nose, doe
(need a value in front)

doss?e dosse, dose, dossse doddoss, dosss


(s in front of ? is
targetted)
+ one or more (dos)+e
(need a value in front)

doss+e
(s in front of ? is
targetted)

is the same as below, but less


resources

\{n\} n times exactly w\{3\} www ww, w, wwww


(need a value in front) (nag){3} = ???

\{n,m\} from n to m times (blah)\{3,5\} blahblahblah, blah,


(need a value in front) blahblahblahblah blahblahblah
blahblahblah
\{n,\} at least n times
(need a value in front)
[] group
\ Escape
\s White Space
\S non-White Space
\d digit character
\D non-digit character
\w Word
\W non-Word (punctuation,
spaces)

You might also like