title: Regular expression to check whitespace in the beginning and end of a string
body: <p>This code supposed not to let strings with whitespaces in the beginning and end. In some reason I have negative result with this code</p>
  
  <pre><code>import re
  def is_match(pattern, string):
      return True if len(re.compile(pattern).findall(string)) == 1 else False
  print(is_match("[^\s]+[a-zA-Z0-9]+[^\s]+", '1'))
  </code></pre>
  
  <p>However, other strings work fine. Can anyone explain why result is negative, or even provide better function (newbie in python).</p>