Skip to main content

Meta Characters

Meta characters give regular expressions their power, allowing for more sophisticated matching.

Special Characters

CharacterDescriptionExampleMatch
|Either orcat|helloMatches "cat" or "hello"
.Any character (except newline)he..loMatches characters between "e" and "l"
Exactly specified number of occurrenceshe.{2}oMatches "hello" where there are exactly 2 characters between "e" and "o"
*Zero or more occurrenceshe.*oMatches "hello", "hero", "helico", etc.
+One or more occurrenceshe.+oSame as above but requires at least one character
?Zero or one occurrencehe.?oMatches "heo" or "hero"
( )Capture and group patterns
[ ]A set of characters[a-z]Matches any lowercase letter
^Starts with^helloMatches strings starting with "hello"
$Ends withworld$Matches strings ending with "world"
\Signals a special sequence\dMatches any digit