Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: remove multiple characters

by bart (Canon)
on Dec 04, 2007 at 10:52 UTC ( #654750=note: print w/ replies, xml ) Need Help??


in reply to remove multiple characters

First of all, don't use "|" as a boolean operator. It is not, it is a bitwise operator. Use "||" instead, for booleans.

And second... why aren't you trying to match just 'b', 'z' or 'y' characters, instead of absolutely anything? That's what regular expressions are for!

$str =~ s/([bzy])//g;

p.s. The capturing parens aren't necessary, but perhaps you may have a use for them yet, so I let them in... But, for this code snippet, you can leave them out. The replacement will probably be faster for it.

$str =~ s/[bzy]//g;


Comment on Re: remove multiple characters
Select or Download Code
Re^2: remove multiple characters
by Punitha (Priest) on Dec 04, 2007 at 11:07 UTC

    Hi bart

    I think dont want that grouping also, you can directly substitute as

    $str =~ s/[bzy]//g;

    Punitha

      It's not just grouping, it's capturing too.

      And I had just finished updating my node, justifying what I did there.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-09-01 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls