Built-in Rules

A number of named rules are provided by default, including a complete set of POSIX-style classes, and Unicode property classes. The list isn’t fully defined yet, but Table 7-7 shows a few you’re likely to see.

Table 7-7. Built-in rules

Rule

Meaning

<alpha>

Match a Unicode alphabetic character.

<digit>

Match a Unicode digit.

<sp>

Match a single-space character (the same as \s).

<ws>

Match any whitespace (the same as \s+).

<null>

Match the null string.

<prior>

Match the same thing as the previous match.

<before . . . >

Zero-width lookahead. Assert that you’re before a pattern.

<after . . . >

Zero-width lookbehind. Assert that you’re after a pattern.

<prop . . . >

Match any character with the named property.

<replace( . . . )>

Replace everything matched so far in the rule or subrule with the given string (under consideration).

The <null> rule matches a zero-width string (so it’s always true) and <prior> matches whatever the most recent successful rule matched. These replace the two behaviors of the Perl 5 null pattern //, which is no longer valid syntax for rules.

Get Perl 6 and Parrot Essentials, Second Edition 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.