Hey guys, I need a regex to remove everything before the price: 314 15 Up to 4 $142.00 Keep in mind that whatever comes before the price won't be the same thing everytime. Can anyone help? Thanks!
Hey, can be before price another '$' sign?? If not, you can use e.g. $string="314 15 Up to 4 $142.00"; preg_match('/^[^$]+(\$\d+\.\d+)$/', $string, $price); then you have price in $price[1]. It also counts, that price format is always '$numbers.numbers' Hope it helps
You can also use: $price = "314 15 Up to 4 $142.00"; $price = explode("$", $price); $price[0] will echo 314 15 Up to 4 and $price[1] will echo 142.00