How to write range character class regex?
To define a character class that includes a range of values, put
"-" metacharacter between the first and last character to be matched. For example
[a-e]. You can also specify multiple ranges like this
[a-zA-Z]. This will match any letter of the alphabet from
z (lowercase) or
In the example below we are matching the word that begins with
bat and ends with a single number that have a value range from
3 to 7.
The program will match the following string from the input:
Text "bat3" found at 12 to 16.
Text "bat4" found at 18 to 22.
Text "bat5" found at 24 to 28.
Text "bat6" found at 30 to 34.
Text "bat7" found at 36 to 40.