Match object
Named Regex
Capturebut 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.p6use 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, ... Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC |
Follow me: