Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
October 8, 2004, 2:27 am
rate this thread
I was wondering how tr/abcd/1234/cs is supposed to work... I intend it
to mean- if its anything other than abcd replace with ... I am not
sure what the right way is.
Without the /c, tr/abcd/1234/s does the expected, replaces each of a
b c and d found, with their corresponding replacement characters. But
in the /c case I notices that any character that was not one of abcd
was replaed with 4, the last character in the REPLACEMENTSTRING 1234.
I tried to look at documentation - they have just one example of
replacing all that dont fit the search with a space. If any of you
have examples of how you use this thing with /c, i'd love to see them.
Re: How does the complement work with transliteration ?
If the "/d" modifier is used, the REPLACEMENTLIST is always
interpreted exactly as specified. Otherwise, if the
REPLACEMENTLIST is shorter than the SEARCHLIST, the final
character is replicated till it is long enough. If the
REPLACEMENTLIST is empty, the SEARCHLIST is replicated. This
latter is useful for counting characters in a class or for
squashing character sequences in a class.
Using a replacement list of more than one character with /c will
give results that depend on what order the complement characters
are listed in the resulting complemented SEARCHLIST.
I don't think that's defined anywhere, but I would assume is would
be in ord() order though how that interacts with unicode strings
I have no idea and the assumption is vaguely supported by:
; perl -de1
DB<2> x $s
DB<4> x $s
I think "don't do that" applies here.
- » query to join two tables in 2 different Oracle schema
- — Previous thread in » PERL Discussions