Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Replace a string that contains special characters

by Corion (Patriarch)
on Mar 21, 2017 at 16:08 UTC ( #1185365=note: print w/replies, xml ) Need Help??


in reply to Replace a string that contains special characters

If you don't really care about leaving the JSON intact, your problem at hand seems to be that Perl regards { and [ and . as special within regular expressions.

To temporarily switch off the special treatment, see the \Q and \E escapes in perlre. Basically, your regexp could be written as:

s/\Q{"absoluteLimits":{"conditionalLimits":[{"bidirVolume":102400000," +name":"Home"}],"resetPeriod":{"volume":"2400 hours"}},"description":" +Promotion_tariffbasic:\E.*//s

(find where I added \Q and \E in the Perl code)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-05-26 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?