fork download
  1. <?php
  2.  
  3. $re = '~(?<!\w)\d+(?:\s+\d+)*(?!\w)~';
  4. $strs = array("Call us on 0800 2458 452 now!","Call us now on 0800 2458 452");
  5. foreach ($strs as $str) {
  6. echo preg_replace($re, '<b>$0</b>', $str) . PHP_EOL;
  7. }
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Call us on <b>0800 2458 452</b> now!
Call us now on <b>0800 2458 452</b>