Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Answer: how do i replace brackets in a regex?

( #160217=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > how do i replace brackets in a regex? 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.

Comment on Answer: how do i replace brackets in a regex?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-31 14:20 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 (278 votes), past polls