Featured image of post Regex Cheatsheet

Regex Cheatsheet

Regex Cheat Sheet

Perl Logo

Perl on Wikipedia

Regular Expressions on Wikipedia

Regex Cheat Sheet

PatternDescription
.Matches any character except a newline
^Matches the start of a string
$Matches the end of a string
\dMatches any digit (0-9)
\DMatches any non-digit
\wMatches any word character (alphanumeric + underscore)
\WMatches any non-word character
\sMatches any whitespace character
\SMatches any non-whitespace character
*Matches 0 or more of the preceding element
+Matches 1 or more of the preceding element
?Matches 0 or 1 of the preceding element
{n}Matches exactly n occurrences
{n,}Matches n or more occurrences
{n,m}Matches between n and m occurrences
[]Matches any one of the enclosed characters
[^]OR operatorMatches any character not in the brackets
()Capturing group
(?=...)Lookahead assertion
(?<=...)Lookbehind assertion
(?!...)Negative lookahead
(?<!...)Negative lookbehind

see https://brianbraatz.github.io/tags/perl/