Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: better way to escape escapes

by kcott (Abbot)
on Apr 16, 2014 at 03:00 UTC ( #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
Node Status?
node history
Node Type: note [id://1082417]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2015-07-06 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (75 votes), past polls