Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Strip brackets and contents from string

by hippo (Bishop)
on Apr 11, 2016 at 14:45 UTC ( [id://1160123]=note: print w/replies, xml ) Need Help??


in reply to Strip brackets and contents from string

But this does not work where the brackets contain only text.

Works for me:

#!/usr/bin/env perl use strict; use warnings; use Test::More; my %foo = ( 'a(b)c' => 'ac', 'ab()cd' => 'abcd' ); my $snr = qr/\(.*?\)/; for my $have (keys %foo) { my $want = $foo{$have}; $have =~ s/$snr//sg; is ($have, $want); } done_testing ();

"It doesn't work" is as useful to a developer as "I'm ill" is to a medic. Try to be more specific.

Replies are listed 'Best First'.
Re^2: Strip brackets and contents from string
by BrowserUk (Patriarch) on Apr 11, 2016 at 20:57 UTC
    "It doesn't work" is as useful to a developer as "I'm ill" is to a medic. Try to be more specific.

    ++ for the accurate analogy. If I could cast another vote for the content of your post I would :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found