develooper Front page | perl.perl6.users | Postings from December 2019

How do I do literal quotes in a regex?

Thread Next
From:
ToddAndMargo via perl6-users
Date:
December 7, 2019 06:47
Subject:
How do I do literal quotes in a regex?
Message ID:
ae4a1260-3b54-96e0-4b76-03a76f2b78f2@zoho.com
Hi All,

Is there a `Q[]` that can be used in a regex?

I am looking for how to get around

my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '\\\\' /x/; say $y
\:x::

This does not work:
my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y
\:\\::

Nor does this:
my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y
x:\\::

Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About