I have the following regex that splits on any space or punctuation. How can I exclude 1 or more punctuation characters from :punct:
? Let's say I'd like to exclude apostrophes and commas. I know I could explicitly use [all punctuation marks in here]
instead of [[:punct:]]
but I'm hoping for an exclusion method.
X <- "I'm not that good at regex yet, but am getting better!"
strsplit(X, "[[:space:]]|(?=[[:punct:]])", perl=TRUE)
[1] "I" "'" "m" "not" "that" "good" "at" "regex" "yet"
[10] "," "" "but" "am" "getting" "better" "!"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…