Embedded regular expression mode modifiers

Like all other regular expression flavors, Java also allows the embedding of some standard modes in the regular expression itself. These mode modifiers are used to change regular expression behavior in a certain manner. In the following table, we will list all these modes and their meaning:

Mode Name Meaning
(?i) Ignore case mode Enables case-insensitive matching for US-ASCII text
(?s) DOTALL mode Makes DOT match all the characters, including line breaks
(?m) Multiline mode Makes the carrot and dollar match the start and end of each line in a multiline input
(?u) Unicode-aware case folding Enables Unicode-aware case folding
(?U) Unicode matching Enables the Unicode version of predefined ...

Get Java 9 Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.