public
Last active

Perl regex escapes by version of their introduction

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# compiled by Tom Christiansen
v1.0 \0, \0N,\0NN Match octal character up to octal 077.
v1.0 \N, \NN, \NNN Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
v4.0 \a Match the alert character (ALERT, BEL).
v5.0 \A True at the beginning of a string only, not in charclass.
v1.0 \b Match the backspace char (BACKSPACE, BS) in charclass only.
v1.0 \b True at Unicode word boundary, outside of charclass only.
v1.0 \B True when not at Unicode word boundary, not in charclass.
v4.0 \cX Match ASCII control character Control-X (\cZ, \c[, \c?, etc).
v5.6 \C Match one byte (C char) even in UTF‑8 (dangerous!), not in charclass.
v1.0 \d Match any Unicode digit character.
v1.0 \D Match any Unicode nondigit character.
v4.0 \e Match the escape character (ESCAPE, ESC, not backslash).
v4.0 \E End case (\F, \L, \U) or quotemeta (\Q) translation, only if interpolated.
v1.0 \f Match the form feed character (FORM FEED, FF).
v5.16 \F Foldcase (not lowercase) till \E, only if interpolated.
v5.10 \g{GROUP} Match the named or numbered capture group, not in charclass.
v5.0 \G True at end-of-match position of prior m//g or pos() setting, not in charclass.
v5.10 \h Match any Unicode horizontal whitespace character.
v5.10 \H Match any Unicode character except horizontal whitespace.
v5.10 \k<GROUP> Match the named (not numbered) capture group; also \k'GROUP', not in charclass.
v5.10 \K Keep text to the left of \K out of match, not in charclass.
v4.0 \l Lowercase (not foldcase) next character only, only if interpolated.
v4.0 \L Lowercase (not foldcase) till \E, only if interpolated.
v1.0 \n Match the newline character (usually LINE FEED, LF).
v5.12 \N Match any character except newline.
v5.6 \N{CHARNAME} Match the named character, named alias, or named sequence, but only if interpolated and "use charnames" loaded.
v5.12 \N{U+XXXXX} Match Unicode character given in any number of hex digits.
v5.14 \o{NNNNNN} Match the character given in any number of octal digits.
v5.6 \p{PROPERTY} Match any character with the named property.
v5.6 \P{PROPERTY} Match any character without the named property.
v4.0 \Q Quote (de-meta) metacharacters till \E.
v1.0 \r Match the return character (usually CARRIAGE RETURN, CR).
v5.10 \R Match any Unicode linebreak grapheme, only outside of charclass.
v1.0 \s Match any Unicode whitespace character except \cK.
v1.0 \S Match any Unicode nonwhitespace character or \cK.
v1.0 \t Match the tab character (CHARACTER TABULATION, HT).
v4.0 \u Titlecase (not uppercase) next character only, only if interpolated.
v4.0 \U Uppercase (not titlecase) till \E, only if interpolated.
v5.10 \v Match any Unicode vertical whitespace character.
v5.10 \V Match any character except Unicode vertical whitespace.
v1.0 \w Match any Unicode “word” character (alphabetics, digits, combining marks, and connector punctuation)
v1.0 \W Match any Unicode nonword character.
v4.0 \xH Match the character given in one hex digit.
v4.0 \xHH Match the character given in two hex digits.
v5.6 \x{HHHHHH} Match the character given in any number of hex digits.
v5.6 \X Match Unicode extended grapheme cluster, only outside of charclass.
v5.5 \z True at end of string only.
v5.0 \Z True right before final newline, or at end of string.

I added a feature request to Perl::MinimumVersion for the use of that table : RT #72250

Also, which of those works in bare qq{} strings? That list would be also helpful for Perl::MinimumVersion.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.