ほとんどのstringr
関数は、対応する関数の単なるラッパーstringi
です。str_replace_all
その一つです。stri_replace_all
しかし、私のコードは、対応するstringi
関数で動作しません。
キャメルケース (のサブセット) を間隔のある単語に変換するための簡単な正規表現を書いています。
なぜこれが機能するのか、私はかなり困惑しています:
str <- "thisIsCamelCase aintIt"
stringr::str_replace_all(str,
pattern="(?<=[a-z])([A-Z])",
replacement=" \\1")
# "this Is Camel Case ain't It"
そして、これはしません:
stri_replace_all(str,
regex="(?<=[a-z])([A-Z])",
replacement=" \\1")
# "this 1s 1amel 1ase ain't 1t"