Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex - Is there any way to control when the contents of a variable are interpolated? (Using "$1" and '$1' in regex replacements)

by kcott (Archbishop)
on Mar 15, 2014 at 08:22 UTC ( [id://1078429]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/env perl -l
    
    ...
    sub replace {
        s/( { | } |{(?!{)|(?<!})})/$replacement_for{$1}/g;
    }
    
  2. or download this
    Initial string:  'a { b } c ( d ) e'
    Replaced string: 'a lbracket b rbracket c ( d ) e'
    Initial string:  'a { b } c ( d ) e {{F}} ((G))'
    Replaced string: 'a lbracket b rbracket c ( d ) e { lbracket F rbracke
    +t } ((G))'
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-26 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found