Skip to content
Regex

Alternation

Match one of several branches.

#alternation#or

Code

regex
cat|dog           cat or dog
(ab|cd)ef         abef or cdef
gr(a|e)y          gray or grey
^(From|Subject):  line starts with From: or Subject:
\b(cat|dog)\b     whole word cat or dog
(?|a(b)|c(d))     branch reset (PCRE)