title: Remove all special characters except a-zA-Z0-9 from a string
body: <p>Is there a way to remove all special characters except a-zA-Z0-9 like in Python with:</p>
  <pre><code>((re.sub(r&quot;[^a-zA-Z0-9]+&quot;, ' ', String)))
  </code></pre>
  <p>As we can use regex, below is the VBA function which can be used.</p>
  <pre class="lang-vb prettyprint-override"><code>Public Function AllClean(TextToReplace As String) As String
      Dim ObjRegex As Object
      Set ObjRegex = CreateObject(&quot;vbscript.regexp&quot;)
      With ObjRegex
          .Global = True
          .Pattern = &quot;[^a-zA-Z0-9_.\s]+&quot;
          AllClean = .Replace(Replace(TextToReplace, &quot;-&quot;, Chr(32)), vbNullString)
      End With
  End Function
  </code></pre>