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 | |
by bart (Canon) on Dec 04, 2007 at 11:11 UTC |
In Section
Seekers of Perl Wisdom