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

Why should you use composite character classes?

We should use composite character classes for the following reasons:

  • To create new custom character classes from predefined Unicode blocks. For example, to match all the letters in an Arabic Unicode block, we can use the following:
[\p{InArabic}&&\p{L}] 
  • To avoid potentially slower lookahead or lookbehind patterns by using the intersection or subtraction operation on multiple character classes.
  • To enhance the readability of the regular expression.

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