~/code/R/
gsub("([ab])", "\\1_\\1_", "abc and ABC")
## [1] "a_a_b_b_c a_a_nd ABC"
## capitalizing txt <- "a test of capitalizing" gsub("(\\w)(\\w*)", "\\U\\1\\L\\2", txt, perl=TRUE)
## [1] "A Test Of Capitalizing"
gsub("\\b(\\w)", "\\U\\1", txt, perl=TRUE)