How to write simple character class regex?
A character class in the context of regular expression is a set of characters enclosed within a square brackets
"". It specifies the characters that will successfully match a single character from the given input.
A simple class, the most basic form of character class, is formed simply by placing a set of characters side-by-side within square brackets. For example the regular expression
b[ai]t will match the words
"bat" because the pattern defines a character class accepting either
"a" as the middle character.
The program will print the following output:
Text "bit" found at 13 to 16.
Text "bat" found at 27 to 30.