01
Getting Started
Basic Syntax
Regex uses special characters for pattern matching. . matches any char, [] defines character classes, \d \w \s are shorthand for common sets. Use ^ inside [] for negation.
regex
# Basic matching
hello # literal match
. # any character except newline
[abc] # any of a, b, c
[^abc] # not a, b, or c
[a-z] # range a to z
\d # digit [0-9]
\D # non-digit
\w # word char [a-zA-Z0-9_]
\W # non-word char
\s # whitespace
\S # non-whitespaceMetacharacters
Metacharacters have special meaning. To match them literally, prefix with a backslash. Inside character classes [], only ] \ ^ and - need escaping (and - only when not at the start/end).
regex