Results 1 to 7 of 7
Thread: advanced regular expressions
- 06-04-2011, 04:33 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 1
- Rep Power
- 0
advanced regular expressions
Hi folks,
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.
Regards,
Ronen
-
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
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
-
- 06-04-2011, 06:30 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
-
- 06-04-2011, 07:59 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
<very intelligent reply>
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>
So there!
kindest regards,
Jos (<-- loves intellectual discussions ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Regular Expressions Help
By Death Sickle in forum New To JavaReplies: 4Last Post: 04-04-2011, 04:21 AM -
Regular Expressions problem
By mohammedelbes in forum Advanced JavaReplies: 7Last Post: 01-05-2011, 11:12 AM -
regular expressions
By sozeee in forum New To JavaReplies: 3Last Post: 12-06-2010, 09:58 PM -
Regular Expressions in java
By blue404 in forum Advanced JavaReplies: 2Last Post: 09-26-2008, 03:43 AM -
Regular expressions quantifiers
By Java Tip in forum Java TipReplies: 0Last Post: 12-25-2007, 11:18 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks