R – Elegant regular expression to match all punctuations but not “‘” in emacs Lisp

regexregex-negation

I want to match all punctuations, but not "'", as in "I'm". For example, in the sentence below:

I'm a student, but I'm also working. 
 ^not match  ^match ^not           ^match

I can use "[[:punct:]]+" to match all punctuations, but I'm having hard time to exclude "'" from the matching pattern.

Of course, I could use someting like the following to express by enumeration, but it's much tedious, especially considering all those punctuations for Chinese as well.
"[,.?!]"

Please suggest a more elegant solution.

Thanks in advance,

Yu

Best Solution

If your regex flavor supports look-arounds, you could do this:

(?!')[[:punct:]]

In plain English: if there's no single quote when looking ahead, match any punctuation mark.