Python regex match space only
<p>In python3, how do I match exactly whitespace character and not newline \n or tab \t?</p>

<p>I've seen the <code>\s+[^\n]</code> answer from   <a href="https://stackoverflow.com/questions/14190038/regex-match-space-not-n">Regex match space not \n</a> answer, but for the following example it does not work:</p>

<pre><code>a='rasd\nsa sd'
print(re.search(r'\s+[^ \n]',a))
</code></pre>

<p>Result is <code>&lt;_sre.SRE_Match object; span=(4, 6), match='\ns'&gt;</code>, which is the newline matched.</p>