fork download
  1. <?php
  2.  
  3. $re = '/\b(?:Apartment|Apt|Block|Department|Lot|Number|Villa)\s*[0-9]+(*SKIP)(?!)|\d+/';
  4. $str = "23 St John Apt 92 rer 4, Wellington Country Block 5 No value test 4545 tt 232";
  5. preg_match_all($re, $str, $matches);
  6. print_r($matches[0]);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 23
    [1] => 4
    [2] => 4545
    [3] => 232
)