O'Reilly logo

Java 9 Regular Expressions by Anubhava Srivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Examples of character range

The following is a regex that matches any uppercase or lowercase alphabet in the English language:

    [a-zA-Z] 

The a-z pattern is for the lowercase character range and A-Z is for the uppercase character range.

The following regex matches any alphanumeric characters:

    [a-zA-Z0-9] 

Alpha numeric characters consist of any English alphabets and digits.

The following regex matches any hexadecimal character:

    [a-fA-F0-9] 

We know that hexadecimal characters consist of digits, 0 to 9, and letters, A to F (ignore casing). The preceding regex pattern shows a character class that includes these two character ranges. We use a-f and A-F ranges to make it match uppercase or lowercase letters.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required