title: SQL Server 2012 : extract Regex groups
body: <p>I have text in my database in Markdown format. I'd like to extract links and count the number of matching links I have. I can get a listing of text blocks that contain links using a query similar to this:</p>
  
  <pre><code>SELECT post_text
  FROM posts p
  WHERE p.body like '%\[%](http%)%' ESCAPE '\'
  </code></pre>
  
  <p>How do I go to the next step though, and just extract the link portion of the text (the part that is in the parenthesis)? If I can get this, I can count the number of times this specific link is in my dataset.</p>
  
  <p>Some sample data:</p>
  
  <pre class="lang-none prettyprint-override"><code>"Visit [Google](http://google.com)"    -&gt; Should return "http://google.com"
  "Get an [iPhone](http://www.apple.com) (I like it better than Android)"   -&gt; Should return "http://www.apple.com"
  "[Example](http://example.com)"    -&gt; Should return "http://example.com"
  "This is a message"    -&gt; Nothing to return on this one, no link
  "I like cookies (chocolate chip)"  -&gt; Nothing to return on this one, no link
  "[Frank] says 'Hello'" -&gt; Nothing to return on this one, no link
  </code></pre>
  
  <p>I am using SQL Server 2012 (if there are differences between versions in this regard).</p>