Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: better way to escape escapes

by kcott (Archbishop)
on Apr 16, 2014 at 03:00 UTC ( [id://1082417]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $any_slash_or_at = qr{ [\\@] }x;
    
  2. or download this
    s/(?<![\\\@])[\\\@]\@/\x11/g;
    s/(?<![\\\@])[\\\@]\\/\x12/g;
    
  3. or download this
    s/$slash_or_at__at/DC1/g;
    s/$slash_or_at__slash/DC2/g;
    
  4. or download this
    #!/usr/bin/env perl -l
    
    ...
    print;
    s/$escape_slash_or_at/$replace{$1}/g;
    print;
    
  5. or download this
    Testing your code:
    \\\ \\@ \@\ \@@ @\\ @\@ @@\ @@@ \\ \@ @\ @@ \ @
    ...
    Testing simultaneous replacements:
    \\\ \\@ \@\ \@@ @\\ @\@ @@\ @@@ \\ \@ @\ @@ \ @
    DC2\ DC2@ DC1\ DC1@ DC2\ DC2@ DC1\ DC1@ DC2 DC1 DC2 DC1 \ @
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1082417]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found