perl6 の正規表現が正規と言えないほど、ぶっ飛んでる構文なのでメモも兼ねて
- Wildcard:
. -
Backslashed character
- digit:
\d - not digit:
\D - alpha plus digit:
\w - not alpha and not digit:
\W - space:
\s - not space:
\S - newline:
\n - horizontal whitespace:
\h - vertical whitespace:
\v
- digit:
-
Predefined character
- digit:
<digit> - alpha plus digit:
<alnum> - space:
<space> - alpha:
<alpha>,<:L> - upper:
<:Lu> - lower:
<:Ll>
- digit:
-
Enumerated character classes
- enumerate:
<[ a b c ]> - range:
<[ a .. c ]> - add:
<[ a .. c ] + [ 1 2 3 ]>==<[ a .. c 1 2 3]> - remove:
<[ a .. c ] - [ b ]>==<[ a c ]> - negate:
<-[ " ]>
- enumerate:
-
Quantifiers
- one or more:
+ - zero or more:
* - zero or one match:
? -
general quantifier:
** count -
general quantifier:
** min..max(This is similar to other languages'{min,max}) -
modified quantifier:
%- e.g. / a+ % ',' / will match a or a,a or a,a,a or so on, but will not match a, or a,a,
-
modified quantifier:
%%- e.g. / a+ %% ',' / will match a or a,a or a,a,a or so on, and also will match a, or a,a,
-
frugal quantifier:
?- e.g. / .+? /
-
preventing backtracking:
:- e.g. / .+: /
- one or more:
- Alternation
-
alternation:
|| -
longest alternation:
|
-
alternation:
-
Anchors
- start of string:
^ - end of string:
$ - start of line:
^^ - end of line:
$$ -
word boundary:
<|w>(This is similar to other languages'\b) -
not word boundary:
<!|w> -
left word boundary:
<<,« -
right word boundary:
>>,»
- start of string:
-
Grouping and Capturing
- matched object:
$/ - capture:
( )- ref:
$0,$1,$2, …
- ref:
- non capturing group:
[ ] - named capture:
$<name>=[ ],$<name>=( )- ref:
$<name>
- ref:
- capture markers:
<( )>(This is similar to other languages'\K)
- matched object:
-
Look-around assertions
-
lookahead assertions:
<?before pattern>- e.g. / foo <?before bar> /
- negated lookahead assertions:
<!before pattern> -
lookbehind assertions:
<?after pattern>- e.g. / <?after foo> bar /
- negated lookbehind assertions:
<!after pattern>
-
lookahead assertions:
-
Subrules
- subrule:
my regex name { regex } - ref:
/ <name> / - non capturing:
/ <.name> /
- subrule:
- Regex Adverbs
-
Matching adverbs
-
continue:
m:c/ pattern / -
exhaustive:
m:exhaustive/ pattern /,m:ex/ pattern / -
global:
m:global/ pattern /,m:g/ pattern / -
pos:
m:pos/ pattern /,m:p/ pattern / -
overlap:
m:overlap/ pattern /,m:ov/ pattern /
-
continue: