title: How to modify this regular expression to not match a non-breaking space?
body: <p>I'm using <a href="http://daringfireball.net/2010/07/improved_regex_for_matching_urls" rel="nofollow">John Gruber's regular expression</a> to try to match URLs in a document.</p>
  
  <p>I've represented the regular expression in Python like this:</p>
  
  <pre><code>URL_PATTERN = re.compile(ur'(?i)\b((?:https?://)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:\'".,&lt;&gt;?\xab\xbb\u201c\u201d\u2018\u2019]))')
  </code></pre>
  
  <p>This is a modified version of a version found <a href="https://gist.github.com/uogbuji/705383" rel="nofollow">here</a>.</p>
  
  <p>This works well in most cases except for documents which contain non-breaking spaces. In Python I see this represented as <code>\xc2\xa0</code>.</p>
  
  <p>Here is an example string that I'm attempting to parse; hopefully the characters will paste in tact:</p>
  
  <pre><code>Go to https://example.com to log in.
  </code></pre>
  
  <p>If I print just that string in Python, I get:</p>
  
  <pre><code>In [100]: string
  Out[100]: 'Go to\xc3\x82\xc2\xa0https://example.com\xc3\x82\xc2\xa0to log in.'
  In [101]: URL_PATTERN.search(string).groups()
  Out[102]: ('https://example.com\xc3\x82\xc2\xa0to', None, None, None, None)
  </code></pre>
  
  <p>The string that I am attempting to match against is an <code>str</code>, not <code>unicode</code>.</p>
  
  <p>How can I modify this regular expression to <strong>not</strong> match this character? I've tried putting <code>\xc2\xa0</code> into the <code>^</code> negated character class near the end of the regex, but it still matches the URL with the space characters.</p>