title: Replace non alphanumeric characters except some exceptions python
body: <p>In perl <code>s/[^\w:]//g</code> would replace all non alphanumeric characters <strong>EXCEPT :</strong></p>
  
  <p>In python I'm using <code>re.sub(r'\W+', '',mystring)</code>
  which does remove all non alphanumeric except _ underscore.
  Is there any way to put exceptions, I wish not to replace signs like = and .</p>
  
  <p>Previously I was applying the other approach i.e. to replace all unwanted characters using<code>re.sub('[!@#\'\"</code>$()]', '',mystring`)
  However, it is not possible for me to predict what all characters may come in mystring hence I wish to remove all non alphanumeric characters except a few.</p>
  
  <p>Google didnt provide an appropriate answer. The closest search being <a href="https://stackoverflow.com/questions/19458601/python-regex-split-any-w-with-some-exceptions">python regex split any \W+ with some exceptions</a> but this didnt help me either.</p>