title: Regex extract some specific number from string, tried several methods
body: <p>I need to extract a specific number from string in variable; for example, <code>$ex</code> is having URLs like <code>&quot;https://www.google.com&amp;r=12345&amp;s=1&amp;t=2&quot;</code>,  and I need to extract <code>12345</code> only. I tried these three regexes but it's not working.</p>
  <ol>
  <li><p>This one returning <code>=12345=1=2</code>.</p>
  <pre class="lang-perl prettyprint-override"><code>$example = $1 if( $ex=~ s/[^=\d]//g);
  </code></pre>
  </li>
  <li><p>This one returning null.</p>
  <pre class="lang-perl prettyprint-override"><code>$example = $1 if($ex=~ m/r\=([\d+])\&amp;/i);
  </code></pre>
  </li>
  <li><p>This one returning null.</p>
  <pre class="lang-perl prettyprint-override"><code>$example = $1 if($ex=~ m/r\^=([\d+])\&amp;/i)
  </code></pre>
  </li>
  </ol>