title: Regular expression for matching non-whitespace in Python
body: <p>I want to use <em>re.search</em> to extract the first set of non-whitespace characters. I have the following pseudoscript that recreates my problem:</p>
  
  <pre><code>#!/usr/bin/env python2.7
  import re
  
  line = "STARC-1.1.1.5             ConsCase    WARNING    Warning"
  m = re.search('^[^\S]*?',line)
  if m:
      print m.group(0)
  </code></pre>
  
  <p>It seems to be printing the whitespace instead of <em>STARC-1.1.1.5</em></p>
  
  <p>So far as I understand it, this regular expression is saying: 
  <em>At the start of the line, find a set of nonwhitespace characters, don't be greedy</em></p>
  
  <p>I was pretty sure this would work, the <a href="https://docs.python.org/2/library/re.html" rel="noreferrer">documentation</a> says I can use /S to match whitespace in [], so i'm not sure where the issue is.</p>
  
  <p>Now, I know, I know this probably looks weird, why aren't I using some other function to do this? Well, there's more than one way to skin a cat and i'm still getting the hang of regular expressions in Python so I'd like to know how I can use re.search to extract this field in this fashion.</p>