title: Find non-alphanumeric characters with alphanumeric character anywhere before
body: <p>So I was writing some code, that would take a String, like &quot;This$#is% Matrix#  %!&quot; and delete all non-alphanumeric symbols, that have alphanumeric symbols somewhere on both surrounding them. I managed to get that, but the problem comes with Strings, that have non-alphanumeric symbols before any other symbols. I wanted to do it with a &quot;non fixed lenght&quot; lookback, but that is not possible. Are there any workarounds?
  Code and some examples:</p>
  <pre><code>decodedString = re.sub(r&quot;[^0-9,a-z,A-Z](?=.+[0-9,a-z,A-Z])&quot;, &quot; &quot;,decodedString)
  print(&quot;1st regex: &quot; + decodedString)
  decodedString = re.sub(r&quot; (?= .+[0-9,a-z,A-Z])&quot;, &quot;&quot;, decodedString)
  print(&quot;2nd regex: &quot; + decodedString)
  </code></pre>
  <p>(The second regex deletes spaces, that are twice in a row, but it should also only delete if an alphanumeric character is before it).</p>
  <p>&quot;#  @i##U&quot; should become &quot;#  @i U&quot;, this one is the only one not working, because it deletes the non-alphanumeric characters at the start (it gives back  &quot;i #U&quot;)</p>
  <p>&quot;This%%is$Matrix%%$script&quot; should become &quot;This is Matrix script&quot;</p>
  <p>&quot;This$#is% Matrix#  %!&quot; should become &quot;This is Matrix#  %!&quot;</p>
  <p>Help would be much appreciated!</p>