Results 1 to 7 of 7
Thread: advanced regular expressions
- 06-04-2011, 04:33 PM #1Member
- Join Date
- Jun 2011
- Rep Power
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.
For regular expressions to work, the data must be regular, must have a definable pattern. Do you know of any patterns that define your data and are never broken?
- 06-04-2011, 06:11 PM #3
- 06-04-2011, 06:30 PM #5
- 06-04-2011, 07:59 PM #7
Your mother was a hamster and your father smelt like elderberries.
</very intelligent reply>
<corollary to very intelligent reply>
:-P :-P :-P
</corollary to very intelligent reply>
Jos (<-- loves intellectual discussions ;-)cenosillicaphobia: the fear for an empty beer glass
- By Death Sickle in forum New To JavaReplies: 4Last Post: 04-04-2011, 04:21 AM
- By mohammedelbes in forum Advanced JavaReplies: 7Last Post: 01-05-2011, 12:12 PM
- By sozeee in forum New To JavaReplies: 3Last Post: 12-06-2010, 10:58 PM
- By blue404 in forum Advanced JavaReplies: 2Last Post: 09-26-2008, 03:43 AM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-25-2007, 12:18 PM