Regular Expressions - A Short Reference Guide
Regular Expressions (Regex) can be difficult to learn, but also very rewarding when mastered. Regex is used to check for specific patterns in strings. This is a quick guide to get started in Regex.
Reference Guide
abc- A plain sequence of characters, matches for exactly “abc”[abc]- Square brackets match for any character in the set, e.g. “a” or “b” both matches[0-9]- A hyphen matches for any character within the range (ordering of unicode), e.g. “1” would match[^abc]- A caret matches for any character except those in the set, e.g. “d” would matchx?- A question mark matches for zero or one occurencesx*- An asterisk matches for zero or more occurencesx+- A plus sign matches for one or more occurencesx{y}- Curly braces matches for exactly y occurencesx{y, z}- Matches for at least y and at most z occurences(x)- Use parentheses to group regular expressionsx|y- Use vertical bars for logical OR\- Use backslash to escape special characters like + and *, or use shortcuts\bas a boundary marker\dfor digits\wfor alphanumeric chars\sfor whitespace (space, tab, newline etc.)\D\W\Sfor any char except digits/alphanumeric/whitespaces
.- dot for any char except newline^- Caret outside of square brackets matches for start of string$- Dollar sign for end of the string