Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: remove multiple characters

by bart (Canon)
on Dec 04, 2007 at 10:52 UTC ( [id://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;

    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://654750]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-19 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found