We can also specify a character range inside a character class by using a hyphen ( - ) between two characters. You just have to make sure that the left-hand side character of a range is lower in the ASCII table than the right-hand side character. We can match all the digits using the regex patterns, [0123456789], or a shorter [0-9].
Range inside a character class
Get Java 9 Regular Expressions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.