Skip to content

Supported regular expression features

The listings are taken from the Perl regex docs. Regular expressions are applied via the regex metafunction.

Currently supported or planned features

Modifiers

Modifier Notes Status
i Do case-insensitive pattern matching. For example, "A" will match "a" under /i. Supported
m Treat the string being matched against as multiple lines. That is, change ^ and $ from matching the start of the string's first line and the end of its last line to matching the start and end of each line within the string. Supported
s Treat the string as single line. That is, change . to match any character whatsoever, even a newline, which normally it would not match. Supported
*x and xx Extend your pattern's legibility by permitting whitespace and comments. For details see: Perl regex docs: /x and /xx. Supported
n Prevent the grouping metacharacters ( and ) from capturing. This modifier will stop $1, $2, etc. from being filled in. Supported
c Keep the current position during repeated matching. Planned

Escape sequences (Complete)

Escape sequence Notes Status
\t Tab (HT, TAB)X Supported
\n Newline (LF, NL) Supported
\r Return (CR) Supported
\f Form feed (FF) Supported
\a Alarm (bell) (BEL) Supported
\e Escape (think troff) (ESC) Supported
\x{}, \x00 Character whose ordinal is the given hexadecimal number Supported
\o{}, \000 Character whose ordinal is the given octal number Supported

Quantifiers (Complete)

Quantifier Notes Status
* Match 0 or more times Supported
+ Match 1 or more times Supported
? Match 1 or 0 times Supported
{n} Match exactly n times Supported
{n,} Match at least n times Supported
{,n} Match at most n times Supported
{n,m} Match at least n but not more than m times Supported
*? Match 0 or more times, not greedily Supported
+? Match 1 or more times, not greedily Supported
?? Match 0 or 1 time, not greedily Supported
{n}? Match exactly n times, not greedily (redundant) Supported
{n,}? Match at least n times, not greedily Supported
{,n}? Match at most n times, not greedily Supported
{n,m}? Match at least n but not more than m times, not greedily Supported
*+ Match 0 or more times and give nothing back Supported
++ Match 1 or more times and give nothing back Supported
?+ Match 0 or 1 time and give nothing back Supported
{n}+ Match exactly n times and give nothing back (redundant) Supported
{n,}+ Match at least n times and give nothing back Supported
{,n}+ Match at most n times and give nothing back Supported
{n,m}+ Match at least n but not more than m times and give nothing back Supported

Character Classes and other Special Escapes (Complete)

Feature Notes Status
[...] Match a character according to the rules of the bracketed character class defined by the "...". Example: [a-z] matches "a" or "b" or "c" ... or "z" Supported
[[:...:]] Match a character according to the rules of the POSIX character class "..." within the outer bracketed character class. Example: [[:upper:]] matches any uppercase character. Supported
\g1 or \g{-1} Backreference to a specific or previous group. The number may be negative indicating a relative previous group and may optionally be wrapped in curly brackets for safer parsing. Supported
\g{name} Named backreference Supported
\k<name> Named backreference Supported
\k'name' Named backreference Supported
\k{name} Named backreference Supported
\w Match a "word" character (alphanumeric plus "_", plus other connector punctuation chars plus Unicode marks) Supported
\W Match a non-"word" character Supported
\s Match a whitespace character Supported
\S Match a non-whitespace character Supported
\d Match a decimal digit character Supported
\D Match a non-digit character Supported
\v Vertical whitespace Supported
\V Not vertical whitespace Supported
\h Horizontal whitespace Supported
\H Not horizontal whitespace Supported
\1 Backreference to a specific capture group or buffer. '1' may actually be any positive integer. Supported
\N Any character but \n. Not affected by /s modifier Supported
\K Keep the stuff left of the \K, don't include it in $& Supported

Assertions

Assertion Notes Status
\b Match a \w\W or \W\w boundary Supported
\B Match except at a \w\W or \W\w boundary Supported
\A Match only at beginning of string Supported
\Z Match only at end of string, or before newline at the end Supported
\z Match only at end of string Supported
\G Match only at pos() (e.g. at the end-of-match position of prior m//g) Planned

Capture groups (Complete)

Feature Status
(...) Supported

Quoting metacharacters (Complete)

Feature Status
For ^.[]$()*{}?+|\ Supported

Extended Patterns

Extended pattern Notes Status
(?<NAME>pattern) Named capture group Supported
(?#text) Comments Supported
(?adlupimnsx-imnsx) Modification for surrounding context Supported
(?^alupimnsx) Modification for surrounding context Supported
(?:pattern) Clustering, does not generate a group index. Supported
(?adluimnsx-imnsx:pattern) Clustering, does not generate a group index and modifications for the cluster. Supported
(?^aluimnsx:pattern) Clustering, does not generate a group index and modifications for the cluster. Supported
(?|pattern) Branch reset Supported
(?'NAME'pattern) Named capture group Supported
(?(condition)yes-pattern|no-pattern) Conditional patterns. Planned
(?(condition)yes-pattern) Conditional patterns. Planned
(?>pattern) Atomic patterns. (Disable backtrack.) Planned
(*atomic:pattern) Atomic patterns. (Disable backtrack.) Planned

Lookaround Assertions

Lookaround assertion Notes Status
(?=pattern) Positive look ahead. Supported
(*pla:pattern) Positive look ahead. Supported
(*positive_lookahead:pattern) Positive look ahead. Supported
(?!pattern) Negative look ahead. Supported
(*nla:pattern) Negative look ahead. Supported
(*negative_lookahead:pattern) Negative look ahead. Supported
(?<=pattern) Positive look behind. Planned
(*plb:pattern) Positive look behind. Planned
(*positive_lookbehind:pattern) Positive look behind. Planned
(?<!pattern) Negative look behind. Planned
(*nlb:pattern) Negative look behind. Planned
(*negative_lookbehind:pattern) Negative look behind. Planned

Special Backtracking Control Verbs

Backtracking control verb Notes Status
(*SKIP) (*SKIP:NAME) Start next search here. Planned
(*PRUNE) (*PRUNE:NAME) No backtracking over this point. Planned
(*MARK:NAME) (*:NAME) Place a named mark. Planned
(*THEN) (*THEN:NAME) Like PRUNE. Planned
(*COMMIT) (*COMMIT:arg) Stop searching. Planned
(*FAIL) (*F) (*FAIL:arg) Fail the pattern/branch. Planned
(*ACCEPT) (*ACCEPT:arg) Accept the pattern/subpattern. Planned

Not planned (Mainly because of Unicode or perl specifics)

Modifiers

Modifier Notes Status
p Preserve the string matched such that ${^PREMATCH}, ${^MATCH}, and ${^POSTMATCH} are available for use after matching. Not planned
a, d, l, and u These modifiers affect which character-set rules (Unicode, etc.) are used, as described below in "Character set modifiers". Not planned
g globally match the pattern repeatedly in the string Not planned
e evaluate the right-hand side as an expression Not planned
ee evaluate the right side as a string then eval the result Not planned
o pretend to optimize your code, but actually introduce bugs Not planned
r perform non-destructive substitution and return the new value Not planned

Escape sequences

Escape sequence Notes Status
\cK control char (example: VT) Not planned
\N{name} named Unicode character or character sequence Not planned
\N{U+263D} Unicode character (example: FIRST QUARTER MOON) Not planned
\l lowercase next char (think vi) Not planned
\u uppercase next char (think vi) Not planned
\L lowercase until \E (think vi) Not planned
\U uppercase until \E (think vi) Not planned
\Q quote (disable) pattern metacharacters until \E Not planned
\E end either case modification or quoted section, think vi Not planned

Character Classes and other Special Escapes

Character class or escape Notes Status
(?[...]) Extended bracketed character class Not planned
\pP Match P, named property. Use \p{Prop} for longer names Not planned
\PP Match non-P Not planned
\X Match Unicode "eXtended grapheme cluster" Not planned
\R Linebreak Not planned

Assertions

Assertion Notes Status
\b{} Match at Unicode boundary of specified type Not planned
\B{} Match where corresponding \b{} doesn't match Not planned

Extended Patterns

Extended pattern Notes Status
(?{ code }) Perl code execution. Not planned
(*{ code }) Perl code execution. Not planned
(??{ code }) Perl code execution. Not planned
(?PARNO) (?-PARNO) (?+PARNO) (?R) (?0) Recursive subpattern. Not planned
(?&NAME) Recursive subpattern. Not planned

Script runs

Script runs Notes Status
(*script_run:pattern) All chars in pattern need to be of the same script. Not planned
(*sr:pattern) All chars in pattern need to be of the same script. Not planned
(*atomic_script_run:pattern) Without backtracking. Not planned
(*asr:pattern) Without backtracking. Not planned