Is there a regex for preserving case pattern in the vein of \\U
and \\L
?
In the example below, I want to convert \
Using the gsubfn
package, you could avoid using nested sub functions and do this in one call.
> library(gsubfn)
> x <- 'Here we have a date, a different Date, and a DATE'
> gsubfn('date', list('date'='month','Date'='Month','DATE'='MONTH'), x, ignore.case=T)
# [1] "Here we have a month, a different Month, and a MONTH"