perl
in の引数を使用してgsub
、個々の部分式の大文字と小文字を変更できます。たとえば、小文字のi
後にアポストロフィまたは文字列の終わり (ここでは冗長) を見つけたい場合は、次のようにします。
gsub("(\\bi(\\b|'))", "\\U\\1", "i am able to move do it as i'm going to.", perl = TRUE)
## [1] "I am able to move do it as I'm going to."
注意事項I
とはいえI'm
キャップでit
はありません。
base とstringiが異なる正規表現エンジンを使用している場合、 stringiを使用して同じことを行うにはどうすればよいですか (それは可能ですか) 。
stri_replace_all_regex("i am able to move do it as i'm going to.", "(\\bi(\\b|'))", "\\U$1")
## [1] "1 am able to move do it as 1'm going to."