Regex Basic Syntax
Basic Matchers
The characters in a regex pattern are called literals. They match themselves.
For example, the regex pattern hello
matches the string hello
.
Dot (.)
The dot .
matches any character except a newline.
For example, the regex pattern h.t
matches hat
, hot
, and hit
.
Character Sets [abc]
A character set matches any one of the characters inside the square brackets.
For example, the regex pattern h[aeiou]t
matches hat
and hit
.
Negated Character Sets [^abc]
A negated character set matches any character that is not inside the square brackets.
For example, the regex pattern h[^aeio]t
matches hut
and hxt
.
Letter Range [a-z]
A letter range matches any one of the characters in the specified range.
For example, the regex pattern [a-z]
matches any lowercase letter.
Number Range [0-9]
A number range matches any one of the numbers in the specified range.
For example, the regex pattern [0-9]
matches any digit.