我有以下正则表达式,可以拆分任何空格或标点符号。如何从中排除 1 个或多个标点符号:punct:
?假设我想排除撇号和逗号。我知道我可以明确地使用[all punctuation marks in here]
而不是,[[:punct:]]
但我希望有一种排除方法。
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" "!"