Camelia
Prev: Match object

Capture

but it can be used in other ways as well using parentheses around parts of the regex will capture those parts:

examples/regex2/match_object_capture.p6
use v6;

my $phone = "054-1234567";

if $phone ~~ m/ (\d+) \- (\d+) / {
    say "prefix: $/[0]";
    say "number:  $/[1]";
    say "full match: $/";
}


the matches are also available as $0, $1, ...


Prev: Match object

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: