develooper Front page | perl.perl6.users | Postings from October 2022

how do I do a literal string in the target of a regex?

Thread Next
From:
ToddAndMargo via perl6-users
Date:
October 29, 2022 20:02
Subject:
how do I do a literal string in the target of a regex?
Message ID:
d0fed43b-1ba2-d7e9-a579-a0447c55e5cd@zoho.com
Hi All,

I am trying to change

      /

into

      \\\

This works:


$ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\\\\\|;print $x 
~ "\n"'
a\\\b\\\c\\\d


But this does not:

$ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|Q[\\\]|;print $x 
~ "\n"'
aQ[\]bQ[\]cQ[\]d


How do I put a literal string in the
target of a regex?

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