too long

I have a string which can take 3 forms (or two if you want):

  • Showing 3 Results
  • Showing 1 - 12 of 79 Results
  • Showing 1 - 12 of 2,513 Results

And what I want is to get the numbers in bold (without comma)...

I can do that using many string functions and conditions, but I'm pretty sure there's an easy and elegant way to do so using regular expressions... which aren't, unfortunately, my strong point.

Use this:

preg_match('/([0-9,]+) Results/', $string, $match);
$number = str_replace(',', '', $match[1]);
$number = preg_replace('/^.*([\d,]+) Results$/', '$1', $original);
$number = preg_relpace('/,/', '', $number);