Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The extended match mode is enabled by a pattern match flag which allows white space and comments to be embedded into the pattern. You can then describe, piece by piece, the parts of the regular expression without dumping those details into the already large header comment suggested above. Pattern match flags are discussed in more detail later in this document.

...

These capture nothing, but activate the match flags "idmsux". These correspond mostly to similarly named flags in Perl:

Match Flags
Center
Wiki Markup
{center}Match Flags{center}

Flag

Java/Groovy

Perl

Description

i

CASE_INSENSITIVE

ignore case

Do case insensitive pattern matching

d

UNIX_LINES

not in Perl

Enables Unix lines mode, only '\n' line terminator affects ., ^ and $

m

MULTILINE

multiline

Enables multiline mode. In multiline mode the expressions ^ and $ match just after or just before, respectively, a line terminator or the end of the input sequence. By default these expressions only match at the beginning and the end of the entire input sequence.

s

DOTALL

single line

In Perl this is called Single-line mode, treating the input as as single line even if it includes line terminators. Normally the "." wildcard doesn't match line terminators, but in Dotall mode it matches all characters.

u

UNICODE_CASE

not in Perl

Enables Unicode-aware case folding.

x

COMMENTS

eXtended

Extended mode allows whitespace, including newlines, and comments beginning with "#" and ending with a newline. Since whitespace in the pattern is ignored, use '\s' to indicate whitespace you wish to match.

g

automatic in Java/Groovy

global

Global matching keeps track of a current position in the input, so you can step through each place the pattern matches the input. Groovy sets up a result array that is an array of arrays of strings. The first dimension represents the number of matches, the second dimension contains the substrings that represent actual text matched and any captured groups.

...