fork(1) download
  1. pascal_to_camel <- function(x) {
  2. tolower(gsub("([a-z0-9])([A-Z])", "\\1_\\2",
  3. gsub("(.)([A-Z][a-z]+)", "\\1_\\2", x)))
  4. }
  5. pascal_to_camel("PaymentDate") # [1] "payment_date"
  6. pascal_to_camel("AccountsOnFile") # [1] "accounts_on_file"
  7. pascal_to_camel("LastDateOfReturn") # [1] "last_date_of_return"
  8.  
  9. pascal_to_camel_uni <- function(x) {
  10. tolower(gsub("([\\p{Ll}0-9])(\\p{Lu})", "\\1_\\2",
  11. gsub("(.)(\\p{Lu}\\p{Ll}+)", "\\1_\\2", x, perl=TRUE), perl=TRUE))
  12. }
  13. pascal_to_camel_uni("ДеньОплаты")
Success #stdin #stdout 0.19s 175424KB
stdin
Standard input is empty
stdout
[1] "payment_date"
[1] "accounts_on_file"
[1] "last_date_of_return"
[1] "день_оплаты"