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>This can be solved with a simple generator expression:</p>

<pre><code>&gt;&gt;&gt; ''.join(ch for ch in stringer if ch not in special)
'M\xc3\xbcllermystringiscool'
</code></pre>

<p><strong>Note that this also removes the spaces</strong>, since they're in your <code>special</code> list (the last element). If you don't want them removed, either don't include the space in <code>special</code> or do modify the <code>if</code> check accordingly.</p>

python regex