我想使用 R 的 gsub 从文本中删除除撇号之外的所有标点符号。我对正则表达式相当陌生,但正在学习。
例子:
x <- "I like %$@to*&, chew;: gum, but don't like|}{[] bubble@#^)( gum!?"
gsub("[[:punct:]]", "", as.character(x))
电流输出(不带撇号)
[1] "I like to chew gum but dont like bubble gum"
期望的输出(我希望撇号不要留下)
[1] "I like to chew gum but don't like bubble gum"