You can also define a range in a character class if the characters appear consecutively. For example, to search for a number between 100 to 109, the pattern would be 10[0-9]
. This returns the same results as 10[0123456789]
, but using ranges makes your regular expressions much cleaner and easier to understand. Ranges can also be used for characters - for example, [a-z]
matches all lowercase characters, or [a-zA-Z]
matches all upper and lower case.