title: How to create Python Regex that replaces characters?
body: <p>I am having trouble in finding the way to create a proper regex that replaces in a string anything different from a-z, A-Z, 0-9 and |.</p>
  
  <p>Until now, I have:</p>
  
  <pre><code> re.sub(r'[\W_]+', '', s)
  </code></pre>
  
  <p>This works fine for alphanumerical characters, but I also need to make it work for pipe ("|"). Does anyone know how to make it?</p>
  
  <p>For example, if I have:</p>
  
  <pre><code>name&amp;|surna.me|ag,e
  </code></pre>
  
  <p>I need it like:</p>
  
  <pre><code>name|surname|age
  </code></pre>