Remove special characters (in list) in string
<p>I have a bunch of special characters which are in a list like:</p>

<pre><code>special=[r'''\\''', r'''+''', r'''-''', r'''&amp;''', r'''|''', r'''!''', r'''(''', r''')''', r'''{''', r'''}''',\
     r'''[''', r''']''', r'''^''', r'''~''', r'''*''', r'''?''', r''':''', r'''"''', r''';''', r''' ''']
</code></pre>

<p>And I have a string:</p>

<pre><code>stringer="MÃ¼ller my [ string ! is cool^&amp;"
</code></pre>

<p>How do I make this replacement? I am expecting:</p>

<pre><code>stringer = "MÃ¼ller my string is cool"
</code></pre>

<p>Also, is there some builtin to replace these âspecialâ chars in Python?</p>

<p>If you remove the space from your specials you can do it using <code>re.sub()</code> but note that first you need to escape the special regex characters.</p>

<pre><code>In [58]: special=[r'''\\''', r'''+''', r'''-''', r'''&amp;''', r'''|''', r'''!''', r'''(''', r''')''', r'''{''', r'''}''',\
     r'''[''', r''']''', r'''^''', r'''~''', r'''*''', r'''?''', r''':''', r'''"''', r''';''']

In [59]: print re.sub(r"[{}]".format(re.escape(''.join(special))), '', stringer, re.U)
MÃ¼ller my  string  is cool
</code></pre>

python regex