fork(1) download
  1. <?php
  2.  
  3. $re = '~(?:\[id:|(?!^)\G,)\K\d+~';
  4. $strs = array("lorem ipsum 999", "[id:284,286]", "[id:28]");
  5. foreach ($strs as $s) {
  6. preg_match_all($re, $s, $matches);
  7. print_r($matches[0]);
  8. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
)
Array
(
    [0] => 284
    [1] => 286
)
Array
(
    [0] => 28
)