>>>>> "WD" == William Dunlap <[email protected]>
>>>>> on Mon, 13 Apr 2009 11:56:51 -0700 writes:
WD> Currently sub(perl=TRUE) allows you to specify \U and \L
WD> in the replacement argument so that the rest of the
WD> subpatterns in the line (the \\<digit> things) will be
WD> converted to upper or lower case, respectively. perl
WD> also also has a \E operator to end these case
WD> conversions for the rest of the subpatterns (so they
WD> retain whatever case they had in the original text).
WD> For symmetry's sake I think it would be nice if R
WD> supported that also. E.g., to capitalize the first and
WD> last letters of every word, leaving the case of the
WD> interior letters alone, could be done with:
>> gsub("(\\w)(\\w*)(\\w)", "\\U\\1\\E\\2\\U\\3", "useRs may
>> fly into JFK
WD> or laGuardia", perl=TRUE) [1] "UseRS MaY FlY IntO JFK OR
WD> LaGuardiA"
>> sub("(\\w)(\\w*)(\\w)", "\\U\\1\\E\\2\\U\\3", "useRs may
>> fly into JFK
WD> or laGuardia", perl=TRUE) [1] "UseRS may fly into JFK or
WD> laGuardia"
WD> A question regarding this came up in r-help today.
WD> Bill Dunlap TIBCO Software Inc - Spotfire Division
WD> wdunlap tibco.com
Thanks a lot, Bill, for your patch!
I have applied and committed it (after testing) to R-devel
[rev. 48321].
Best regards,
Martin Maechler, ETH Zurich
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel