[EMAIL PROTECTED] wrote: > The C<:ii> variant may be used on a substitution to change the > substituted string to the same case pattern as the matched string. > -Case info is carried across on a character by character basis. If > -the right string is longer than the left one, the case of the final > -character is replicated. > +Case info is carried across on a character by character basis. If the > +right string is longer than the left one, the case of the final > +character is replicated. Titlecase is carried across if possible > +regardless of whether the resulting letter is at the beginning of > +a word or not; if there is no titlecase character available, the > +corresponding uppercase character is used. (This policy can be > +modified within a lexical scope by a language-dependent Unicode > +declaration to substitute titlecase according to the orthographic > +rules of the specified language.)
what happens if some of the characters aren't cased at all, like white
spaces?
my $str = "AB DE";
$str ~~ s:ii/.*/abcde/;
is the result ABcDE ? or is the space ignored and the substition is
performed as if $str was "ABDE" in the first place?
IMHO the current behaviour is not very DWIMmy.
Instead I'd suggest to check if the matched string is
* all lowercase
* all uppercase
* firsts letter upper, rest lower
* the other way round
* Capitalized (first char of each word is upper)
and if any of these hold true (checked in this order), then the same
casing rule is applied to the substitution string.
> @@ -212,7 +218,8 @@
> substituted string to the same accent pattern as the matched string.
> Accent info is carried across on a character by character basis. If
> the right string is longer than the left one, the remaining characters
my $str = "määh";
$str =~ s:bb/.*/mo i/;
is $str now 'mö i' ? Or does the space get a \N{COMBINING DIAERESIS}? Or
is it tranlated to \N{DIAERESIS}? What about other non-letter characters?
--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/
signature.asc
Description: OpenPGP digital signature
