title: Finding links with spaces with regex
body: <p>For some reason the following regex is not behaving as I would expect.</p>
  
  <p>I am trying to extract all links from a html creative, although I can't seem to find a way to handle links with spaces properly.</p>
  
  <p>I know that links should be encoded, but there is no way to encode the links if I cannot find them.</p>
  
  <p>I am testing against this html - notice that the only difference is the space in {your reference}.</p>
  
  <pre><code>Find out &lt;a href="http://website.co.uk?element=1&amp;amp;reference={your reference}"&gt;&lt;span style="color:#000000;"&gt;what something is here&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;br /&gt;
  
  Find out &lt;a href="http://website.co.uk?element=1&amp;amp;reference={yourreference}"&gt;&lt;span style="color:#000000;"&gt;what something is here&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;br /&gt;
  </code></pre>
  
  <hr>
  
  <p>With the following regex I can only get the link without any spaces as is expected:</p>
  
  <pre><code>href="http(s{0,1}):\/\/(\S+)"
  </code></pre>
  
  <p>Finds:</p>
  
  <pre><code>href="http://website.co.uk?element=1&amp;amp;reference={yourreference}"
  </code></pre>
  
  <p>However if I change the \S to a . I expect the check to return the link up to the closing ", but it continues almost to the end of the string:</p>
  
  <pre><code>href="http(s{0,1}):\/\/(.+)"
  </code></pre>
  
  <p>Finds:</p>
  
  <pre><code>href="http://website.co.uk?element=1&amp;amp;reference={your reference}"&gt;&lt;span style="color:#000000;"&gt;what something is here&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"
  
  href="http://website.co.uk?element=1&amp;amp;reference={yourreference}"&gt;&lt;span style="color:#000000;"&gt;what something is here&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"
  </code></pre>
  
  <hr>
  
  <p>I also have a number of different checks to pick up different links, the final looks like this:</p>
  
  <pre><code>(href="|href=\')%%siteurl%%(\S*)("|\')
  |href="www\.(\S+)"
  |href="http(s{0,1}):\/\/(\S+)"
  |href=\'www\.(\S+)\'
  |href=\'http(s{0,1}):\/\/(\S+)\'
  </code></pre>
  
  <p>I am not looking for help for this set, just the original regex posted and I will adjust the rest accordingly.</p>