On Wednesday, June 11, 2003, at 05:14 AM, Jaschar Otto wrote:
$string =~ s/[^abcd]//g;
Thanks a lot, that worked perfect,
Transliterate is probably a better choice for this kind of thing. It's certainly more efficient. You would use it like this:
Just curious, how is it more efficient?
Transliterate is faster because it doesn't have to fire up the Regular Expression engine.
Can you use anchors in tr ?
No, but there were no anchors used in the above search. The problem was to replace all non qw(a b c d) characters with a space. That's a textbook perfect definition of what Transliterate does.
because in the =~ example above it would match a string: abcd foo monkey But not monkey abcd foo While the tr version would match both.
Na, you're confusing your ^ characters. ;) What you said is written:
s/^abcd/ /;
The search above was:
s/[^abcd]/ /;
It means any non qw(a b c d) character.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]