Edit: use this as an example if your data is formatted very accurately. As Strager noted, in most cases there will be too many changes to the data to use the regular expression effectively.
Assuming your input is in the format:
[Street Name], [State], [ZIP], [Country]
This regex will do the trick:
m/^(.+?),(.+?),([0-9]+),(.+)$/
But regular expressions are quite complicated ... if you are going to use this for something significant, I would suggest spending time learning Regexes. I always found this trickster very useful:
http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/
source share