title: Using regex to match non-word characters BUT NOT smiley faces
body: <p>I have a Java program which is supposed to remove all non-letter characters from a string, except when they are a smiley face such as =) or =] or :P</p>
  
  <p>It's very easy to match the opposite with <code>[a-zA-Z ]|=\)|=\]|:P</code> but I cannot figure out how to negate this expression. Since I am using the String.replaceAll() function it must be in the negated form.</p>
  
  <p>I believe part of the issue may come from the fact that smiles are generally 2 characters long, and I am only matching 1 character at a time?</p>
  
  <p>Interestingly, <code>replaceAll("(?![Tt])[Oo]","")</code> removes every occurrence of the letter O, even in the word "to." Does this mean my replaceAll function does not understand regex lookahead? It doesn't throw any errors...</p>
  
  <p>I ended up using</p>
  
  <pre><code>replaceAll("(?&lt;![=:;])[\\]\\[\\(\\)\\/]","")
  .replaceAll("[=:;](?![\\]\\[\\(\\)o0OpPxX\\/])","")
  .replaceAll("[^a-zA-Z=:;\\(\\)\\[\\]\\/ ]","")
  </code></pre>
  
  <p>which is extremely messy but works perfectly. <code>The... quick! (brown) fox jump's over the[] lazy dog. :] =O ;X</code> becomes <code>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG :] =O ;X</code></p>
  
  <p><strong>Edit:</strong> Ignore that fix, see the accepted answer below.</p>