How to move all special characters to the end of the string in Python?
<p>I'm trying to filter all non-alphanumeric characters to the end of the strings. I am having a hard time with the regex since I don't know where the special characters we be. Here are a couple of simple examples. </p>

<pre><code>hello*there*this*is*a*str*ing*with*asterisks
and&amp;this&amp;is&amp;a&amp;str&amp;ing&amp;&amp;with&amp;ampersands&amp;in&amp;i&amp;t
one%mo%refor%good%mea%sure%I%think%you%get%it
</code></pre>

<p>How would I go about sliding all the special characters to the end of the string?</p>

<p>Here is what I tried, but I didn't get anything.</p>

<pre><code>re.compile(r'(.+?)(\**)')
r.sub(r'\1\2', string)
</code></pre>

<p><strong>Edit:</strong></p>

<p>Expected output for the first string would be:</p>

<pre><code>hellotherethisisastringwithasterisks********
</code></pre>