fork download
  1. <?php
  2.  
  3. $links = <<< LOB
  4. my-domain/product/name-product-ID123.html
  5. my-domain/product/name-product-ID123.html/
  6. my-domain/product/name-product-ID123.html?bla=123&some=456
  7. LOB;
  8.  
  9. preg_match_all('/-(ID\d+)\./',$links ,$ids, PREG_PATTERN_ORDER);
  10. for ($i = 0; $i < count($ids[1]); $i++) {
  11. echo $ids[1][$i]."\n";
  12. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
ID123
ID123
ID123