advanced regular expressions
Excuse me if this question has already been asked, i searched but could not find it.
What i need to do is use regular expressions to parse text that contains a location, such as "Las Vegas, Nevada, USA". However, I need the regular expression to look like "<city>, <state>, <country>" since there can be many values for cities, states, and countries. This is a textbook example for the java.util.regex.Pattern and java.util.regex.Matcher classes except for the fact I don't want to write a regular expression such as "Las Vegas|San Francisco|New York|.....". There are many cities, states, and countries in the world. I need to be able to customize it such as whenever the Pattern class sees the text "<city>", it should match against a particular list of valid values.
This may be solvable with a framework like ANTLR, but I'm wondering whether it can be done using plain Java.