quote / /

Documentation for quote / / assembled from the following types:

language documentation Regexes

From Regexes

(Regexes) quote / /

Perl 6 has special syntax for writing regexes:

m/abc/;         # a regex that is immediately matched against $_ 
rx/abc/;        # a Regex object; allow adverbs to be used before regex 
/abc/;          # a Regex object; shorthand version of 'rx/ /' operator 

For the first two examples, delimiters other than the slash can be used:

m{abc};
rx{abc};

Note that neither the colon nor round parentheses can be delimiters; the colon is forbidden because it clashes with adverbs, such as rx:i/abc/ (case insensitive regexes), and round parentheses indicate a function call instead.

Example of difference between m/ / and / / operators:

my $match;
$_ = "abc";
$match = m/.+/say $matchsay $match.^name# OUTPUT: «「abc」␤Match␤» 
$match =  /.+/say $matchsay $match.^name# OUTPUT: «/.+/␤Regex␤» 

Whitespace in regexes is generally ignored (except with the :s or, completely, :sigspace adverb).

Comments work within a regular expression:

/ word #`(match lexical "word") /