fork(3) download
  1. <?php
  2.  
  3. $re = '~\b\d{4}\b\+?~';
  4. $str = 'Please message mpg of jazz 2014 and 2015+ to my mobile number +123456789';
  5. if (preg_match_all($re, $str, $matches)) {
  6. print_r($matches[0]);
  7. }
  8.  
Success #stdin #stdout 0.02s 24032KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 2014
    [1] => 2015+
)