You can still use m// as a regex but as you can see spaces in the regex are non significant. It is quite similar to the effect of /x option in PCRE.
In Perl 6 the smart match ~~ operator is used for regex matching.For negative matching use the !~~ operator.
tutorial/regex2/simple.p6
use v6; my $text = "Learning regexes"; if $text ~~ m/ regex / { say "This is about regexes!"; } if $text !~~ m/ foobar / { say "No foobar in $text"; }
Regex in Perl 6 disregard spaces by default. People who are used to the Perl 5 style regular expressions - which means basically every programming language that has a regular expression library - will usuall think as spaces being significant in the regular expressions.
We will have to unlearn that and think about the individual bits and pieces that are the tokens we would like to match.
Basically Perl 6 regexes work as if you always had the /x modifyer on which in Perl 5 means disregard spaces and treat # as start of comment.
Published on 2012-01-01