Camelia
Prev: Word boundary

Named Regex

let's create the named regexes for the word and duplicate:

examples/regex2/named_regex2.p6
use v6;

my $s = 'The elvish brown fox jumped over the the lazy dog';
my regex word { \w+ [ \' \w+]? }
my regex dup  { << <word=&word> \W+ $<word> >> }

if $s ~~ m/ <dup=&dup> / {
    say "Found '{$<dup><word>}' twice in a row";
}


Prev: Word boundary

Table of Contents

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: