I'd like to use R's gsub to remove all punctuation from a text except for apostrophes. I'm fairly new to regex but am learning.
Example:
x <- "I like %$@to*&, chew;: gum, but don't like|}{[] bubble@#^)( gum!?"
gsub("[[:punct:]]", "", as.character(x))
Current Output (no apostrophe in don't)
[1] "I like to chew gum but dont like bubble gum"
Desired Output (I desire the apostrophe in don't to stay)
[1] "I like to chew gum but don't like bubble gum"
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…