I want to get first number from the string before the word 'minimum', preceeded by a space and not succeeded by '-'. Example:
- shouldn't match the words 2-3, TT-89 etc; (ie, a number followed by - and another number or alphabets followed by - and numbers)
- should match the word 2-rolls (ie, a number followed by - and alphabets)
I'm trying with the following code:
$str = "Red QQ-4555 White TT-789 Yellow Minimum order applies. This is a test";
$explodeByMinimumArray = preg_split("/minimum/i", str_replace(array( '(', ')' ), ' ', $str));
preg_match_all('/\d+(?!-\d)/', $explodeByMinimumArray, $numberFromStringBeforeMinimumArray);
This is returning
 => Array
 => 4555
 => 789
But the expected output is empty as QQ-4555 and TT-789 are preceeded by some characters.
Can anyone help me to fix this? Thanks in advance.