fork download
  1. A <- c("Hello world", "Green 44", "Hot Beer", "Bip 6t")
  2. sub("([[:alpha:]]+)", "*\\1*", A)
  3. ## => "*Hello* world" "*Green* 44" "*Hot* Beer" "*Bip* 6t"
  4.  
  5. library(stringr)
  6. stringr::str_replace(A, "([[:alpha:]]+)", "*\\1*")
  7. stringr::str_replace(A, "(\\p{L}+)", "*\\1*")
Success #stdin #stdout 0.29s 42500KB
stdin
Standard input is empty
stdout
[1] "*Hello* world" "*Green* 44"    "*Hot* Beer"    "*Bip* 6t"     
[1] "*Hello* world" "*Green* 44"    "*Hot* Beer"    "*Bip* 6t"     
[1] "*Hello* world" "*Green* 44"    "*Hot* Beer"    "*Bip* 6t"