Here's my test code:
$strings=array(
'Low Minimum',
'Low 10 Piece Minimum',
'10 piece minimum',
'20 piece minimum',
'low 6 piece minimum',
'100 piece minimum',
'This item is offered with a 1000 piece minimum',
'Place your order now. This item has a 75 piece minimum',
'Place your order now. This item has a low 75 piece minimum',
);
foreach($strings as $string)
{
echo preg_replace('/(low)? ?(\b[0-9]{0,3}\b) (piece minimum)/i',' Low Minumum',$string);
echo '<br>';
}
Here's the output:
Low Minimum
Low Minumum
Low Minumum
Low Minumum
Low Minumum
Low Minumum
This item is offered with a 1000 Low Minumum
Place your order now. This item has a Low Minumum
Place your order now. This item has a Low Minumum
Here is my desired output:
Low Minimum
Low Minumum
Low Minumum
Low Minumum
Low Minumum
Low Minumum
This item is offered with a 1000 piece minimum
Place your order now. This item has a Low Minumum
Place your order now. This item has a Low Minumum
The one that messes me up is the 4 digit number. So, "piece minimum" should only match if some part of what's before it also matched. How do I write this?