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

Use predefined character classes instead of longer versions

We discussed predefined character classes and Unicode character classes in Chapter 2, Understanding the Core Concepts of Java Regular Expressions. We need to make good use of it. So use \d instead of [0-9] or \D instead of [^0-9], and use \w instead of [a-zA-Z_0-9] or \W instead of [^a-zA-Z_0-9].

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