Skip to main content

A regular expression to match any occurence of "Jon", "John" or "Jonathan" in a string.

\bjo?h?n(?:athan)?\b

\b          # Assert position at a word boundary
j           # Match the character "j" literally
o           # Match the character "o" literally
?           # Between zero and one times, as many times as possible, giving back as needed (greedy)
h           # Match the character "h" literally
?           # Between zero and one times, as many times as possible, giving back as needed (greedy)
n           # Match the character "n" literally
(?:         # Match the regular expression below
athan       # Match the characters "athan" literally
)?          # Between zero and one times, as many times as possible, giving back as needed (greedy)
\b          # Assert position at a word boundary