
Perl 5.16 and prior treat them as literals. Perl 5.22 and later ignore non-ASCII line breaks. Perl always treats non-ASCII spaces as literals. JGsoft V1 almost does but misses the next line control character (U+0085). JGsoft V2 and Boost are the only flavors that ignore all Unicode spaces and line breaks. All flavors discussed in this tutorial ignore the ASCII space, tab, line feed, carriage return, and form feed characters. This is true for all such constructs, including lookaround, named groups, etc.Įxactly which spaces and line breaks are ignored depends on the regex flavor. The ?> grouping modifier is a single element in the regex syntax, and must stay together. (?> atomic ) is the same as (?> ato mic ) and as ( ?> ato mic ). Likewise, grouping modifiers cannot be broken up. Breaking up the token with a space gives you an escaped space (which matches a space), and a literal “d”. \d is a single regex token composed of a backslash and a “d”. The former matches d, while the latter matches a digit. a b c is the same as abc in free-spacing mode. Note that only whitespace between tokens is ignored. Whitespace includes spaces, tabs, and line breaks.

In free-spacing mode, whitespace between regular expression tokens is ignored. With flavors that support mode modifiers, you can put (? x ) the very start of the regex to make the remainder of the regex free-spacing. The mode is usually enabled by setting an option or flag outside the regex. Plain JavaScript doesn’t either, but XRegExp does.

Of the flavors discussed in this tutorial, only XML Schema and the POSIX and GNU flavors don’t support it. This mode allows for regular expressions that are much easier for people to read. Most modern regex flavors support a variant of the regular expression syntax called free-spacing mode.
