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

Disabling mode modifiers

To disable a previously enabled mode, we can place a hyphen (-) before the modifier symbol anywhere in your regular expression.

Let's look at some examples.

To disable DOTALL, we can use the following regex:

    (?-s) 

To disable ignore case matching, we can use the following regex:

    (?-i) 

To disable the MULTILINE mode, we can use the following regex:

    (?-m)

To disable both ignore case and MULTILINE mode, we can use the following regex:

    (?-im)

To disable the ignore case, DOTALL, and MULTILINE modes, we can use the following regex:

    (?-ism)

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