How do I create regex groups for replacement?
- by resting
I have this sample string:
Image: SGD$45.32 SKU: 3f3f3 dfdfd grg4t BP 6yhf Pack Size: 1000's Color: Green Price: SGD$45.32 SGD$45...
I would like to remove all the prices namely:
SGD$45.32
Price: SGD$45.32
SGD$45
I have this expression thats supposed to match the 3 groups:
$pattern = '/(Price.+\sSGD\$\d+\.\d{2})(SGD\$\d+\.\d{2})(SGD\$\d+)/';
$new_snippet = preg_replace($pattern, '', $snippet);`
But apparently its not working.
It works if I replace a single group at a time. But, I'd like to know if it possible to replace all possible matching groups with a single statement.
Tried preg_match_all($pattern, $snippet, $matches); to show matches based on the above pattern, but no matches are found if I put all 3 groups together.