From: Chris Nandor <[EMAIL PROTECTED]>
>At 12:49 -0500 02.02.2001, Kenneth Graves wrote:
>>(I.e., why don't character classes work in tr? \s and \S would be
>>very convenient.)
>
>\d is not a character class, but a metacharacter. And I guess the answer
>to "why not" is that metacharacters are for regexes, and tr/// does not use
>regexes. It only looks like it does.
\n is a metacharacter, and does work in tr. The metacharacters that
encode single characters work in tr like they do in an interpolated
strings. The metacharacters that match multiple characters in a regex
don't work in tr. The problem is, my brain keeps insisting that
tr/thesechars//d;
is "really" an optimized version of
s/[thesechars]//g; # or [theschar]
and I keep trying to do
tr/\s//d; # doesn't eliminate whitespace
I've managed to train a neuron or two to stop making that mistake,
but it's still annoying. With utf8, I'd want to eliminate whitespace
with something like
tr/[:space:]//d;
since I have no hope of memorizing the utf8 equiv of " \t\r\n\f".
--kag