Regular Expression needed in PHP for matching all but last numbers and comma in a variable
Posted on 2004-10-16
I am working in PHP and using preg_match to try to retrieve the following.
$line = " Liatris spicata `Floristan Violet' DND 1 4,111" (yes, there are multiple spaces in there).
Essentially I need to pull out two different variables from this $line: $product, and $quantity, which should be as follows:
$product = "Liatris spicata `Floristan Violet' DND 1" (notice I stripped spaces before and after)
$quantity = "4,111" (I basically want to do a search starting from the last character of the line, moving left until the first SPACE I find, but I DO want to include commas, since this is a quantity variable)
Any help please? Thanks so much.