regex for preserving case pattern, capitalization

前端 未结 3 780
无人共我
无人共我 2020-12-03 23:09

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

In the example below, I want to convert \

3条回答
  •  -上瘾入骨i
    2020-12-04 00:02

    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"
    

提交回复
热议问题