Dear Members,
Each line ends with a dollar amount (although some lines have a dollar amount in the middle).
Here is a line:
$string = ‘123456 JONES: Spirit of the Ocean, originally 5.00 with coupon. 200 Pages 4.99 (used)’;
NON-working code:
preg_match("/^\d{6}.?[A-Z+]:.\d*.\d{2}/",$string,$match);
print_r($match);
How do I match the middle (everything between the colon “:” and the price closest to “end-of-line”)?
Spirit of the Ocean, originally 5.00 today. 200 Pages
How do I match just the price?
4.99
If I put parentheses where I think they should go, I get a bad result:
preg_match("/^\d{6}.?[A-Z+]: (.) (\d*.\d{2})/",$string,$match);
print_r($match);
$match[1] => Spirit of the Ocean, originally 5.00 with coupon. 200 Pages 4 (lops off the “.99”)
$match[2] => .99 (lops off the ‘4’)
I’ve tried shifting around the parentheses of no avail. Please help?
Thank you!!