I am learning how to extract data from a string of data to define as variables and use as I'd like. The data source I am parsing is a standard email every time and the address is exactly the same punctuation and format each time. The only difference is that sometimes the zip-code may be the 9-digit code.
123 Riverview Pkwy, Orlando, FL 55556
123 Riverview Pkwy, Orlando, FL 55556-1234
I was able to extract the city like this:
preg_match('/, (.*?)\,/', $xaemailpaste, $insuredcity1);
$insuredcity = $insuredcity1[1];
And that will return "Orlando" perfectly, but I can't get the address, state or zip. Can someone please help me with a regular expression to assign variables to each component?
$streetaddress = 123 Riverview Pkwy
$city = Orlando
$state = FL
$zip = 55556
I have had some success with regex and I'm excited to learn more, but I have spent 2 days trying stuff and looking up things to try and I can't get the expression just right for my exact needs.