Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Answer: how do i replace brackets in a regex?

by Schuk (Pilgrim)
on Apr 18, 2002 at 14:37 UTC ( #160217=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > how do i replace brackets in a regex? - Answer contributed by Schuk

or

$journal =~ s/(\)|\()//g;

"s" for replace
"\)" and "\(" for escaping the brackets
"|" for or
and the whole thing in "(..)" because you want to replace it with nothing "//"
"g" finally stands for global -> replacement doesnt stop when you hit the first bracket.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[GotToBTru]: you could, yes
[GotToBTru]: whether or not it would be the best tool for that job .. that is another question

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-02-22 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (335 votes). Check out past polls.