How to remove non alphanumeric characters while keeping unicode encoded chars AND apostrophe ( \' )?
<p>I have a text where I want to remove all nonalphanumeric characters, but keep unicode encoded characters AND apostrophe, since it's part of words like wasn't, couldn't, French contractions, etc. I know I can do <code>re.sub(ur'\W', '', text, flags = re.UNICODE)</code> to remove all nonalphanumeric characters, but I'm not sure how to do the same to preserve the apostrophe.  Clearly <code>re.sub(ur'[^A-Za-z0-9\'], '',text)</code> doesn't work because it would get rid of unicode encoded characters. Any ideas? </p>