Pattern Matching Using Quantifiers
Matching specific characters
We use []
square brackets for matching specific characters using regular expressions. We use brackets to find a set of characters. See examples below:
[ABC]
: Character class representing eitherA
,B
, orC
.[^ABC]
: Character class with negation, any character other thanA
,B
, orC
.[0-9]
: Any numeric character, either of0
,1
,2
…8
, or9
.[^0-9]
: Any character other than0
,1
,2
…8
, or9
.
Get hands-on with 1400+ tech skills courses.