Simple Regular Expression Patterns
Simple Single-character Patterns are :
- Single explicit character e.g. a
- dot . which matches ANY character except newline \n
Character class is a Single-character Pattern and represented as a set [c1c2c3...cN] which matches any one of the listed characters
- [ABCDE] matches A B C D or E
- [0-9] is same as [0123456789]
- [a-zA-Z] matches any lower or upper case letter
Negated character class is represented by a carat ^ after left [ square bracket
- [^0-9] matches any character which is NOT a digit 0 1 2 3 4 5 6 7 8 9 (there is another critical use of ^ -- see later)
There are a set of special character classes shown overleaf such as \w which is equivalent to [A-Za-z0-9_].