**Is there a regex for preserving case pattern in the vein of `\U` and `\L`?** 

In the example below, I want to convert `"date"` to `"month"` while maintaining the capitalization used in the `input`

```
   from        to
  "date" ~~> "month"
  "Date" ~~> "Month"
  "DATE" ~~> "MONTH"

```

I currently use three nested calls to `sub` to accomplish this. 

```
input <- c("date", "Date", "DATE")
expected.out <- c("month", "Month", "MONTH")

sub("date", "month", 
  sub("Date", "Month", 
    sub("DATE", "MONTH", input)
  )
)

```

The goal is to have a single `pattern` and a single `replace` such as 

```
gsub("(date)", "\\Umonth", input, perl=TRUE) 

```

which will yield the desired output