How to clean a string using python regular expression
<p>I have the following string which have to clean</p>

<pre><code>#import re

addr="abcd&amp;^fhj"
problemchars = re.compile(r'[=\+/&amp;&lt;&gt;;\'"\?%#$@\,\. \t\r\n]')
re.search(problemchars,addr)
</code></pre>

<p>you could use the filter function as well if you don't want to go with regex</p>

<pre><code>line = "abcd&amp;^fhj"
line = filter(str.isalpha, line)
print line # Change for python3 
</code></pre>

<p>Output : </p>

<pre><code>abcdfhj
</code></pre>

<p>Edit: For python 3 you could change the print statement like this</p>

<pre><code>print(''.join(list(line)))
</code></pre>

python regex