fork download
  1. <?php
  2.  
  3. $str= '<li>111-37774 Blue</li><li>111-1566 Red</li><li>122-4555 White</li><li>1455-789 Yellow</li></ul>Minimum order applies. This is a string for testing.<p>';
  4. $regexForPattern ='/((?:\S+\s+){0,5})minimum\b((?:\s+\S+){0,5})/i';
  5. $nstr = trim( preg_replace('#<[^>]+>#', ' ', $str));
  6. echo $nstr . "\n";
  7. preg_match_all ($regexForPattern , $nstr, $patternMatches);
  8. print_r($patternMatches);
Success #stdin #stdout 0.02s 23828KB
stdin
Standard input is empty
stdout
111-37774 Blue  111-1566 Red  122-4555 White  1455-789 Yellow  Minimum order applies. This is a string for testing.
Array
(
    [0] => Array
        (
            [0] => Red  122-4555 White  1455-789 Yellow  Minimum order applies. This is a
        )

    [1] => Array
        (
            [0] => Red  122-4555 White  1455-789 Yellow  
        )

    [2] => Array
        (
            [0] =>  order applies. This is a
        )

)