The placement of embedded modes in a Java regular expression

All the aforementioned embedded modes can be placed at the start of a regular expression to enable one or more modes for the complete regular expression. We can also place these modes in the middle of a regex to enable it for a specific group or a remainder of the regex pattern.

We can also combine multiple mode modifiers into a single expression like this:

    (?is)

This enables the DOTALL and ignore case modes.

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.