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

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;

Replies are listed 'Best First'.
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;


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

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-11-28 06:01 GMT
Find Nodes?
    Voting Booth?

    No recent polls found