title: Replace all of string except specific words when using pandas python replace string
body: <p>I am forming a new column in a pandas dataframe and I want to enter the short name for operating systems.
  I am using regex and need to exact match words to exclude from the selection however when I change the regex to not select the words it then stops exact matching. I have read as many regex exact match word posts here as possible and none of the solutions work.</p>
  <p>so for example I have data which looks like this:</p>
  <pre><code>Android 10kdsh
  Chrome OS
  Linux ddk2
  OS X 10.
  Windows 7
  iOS c
  </code></pre>
  <p>and I want it to look like this:</p>
  <pre><code>Android 
  Chrome
  Linux
  OS X
  Windows
  iOS
  </code></pre>
  <p>I tried code as follows:</p>
  <pre><code>def short_OS(webchat):
  
      webchat[&quot;OS&quot;] = webchat[&quot;Operating System&quot;].str.replace(('[^(Android|^OS X|^Chrome|^Linux|^Windows|^iOS)]'),&quot;&quot;, regex = True)
  
      return webchat
  </code></pre>
  <p>but this leaves some of the characters in as leaving:</p>
  <pre><code>Androiddsh
  ChromeOS
  Linuxdd
  OS X
  Windows
  iOS
  </code></pre>
  <p>obviously the above are just examples but the principle about some of the characters being left in as they are in the words are the same.</p>
  <p>I should note that framing the words with \b did not change the outcome. and if I use the $ for the end of string, in the example of 'Android' it still leaves the '10kdsh' in on the same line</p>
  <p>can anyone help please?</p>
  <p>thank you</p>