Results 1 to 4 of 4
Thread: parsing multiple delimiters
- 04-18-2009, 11:04 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
parsing multiple delimiters
I have to input and parse the contents of a .txt file. I can do this using Scanner class and defining a delimiter (e.g. scanner.useDelimiter(",");)
However, my txt file has multiple delimiters. For example, this is a snippet of the file:
Question: Question text goes here Location: Chicago, IL School: Unit 5 Grade: 8 Question: Question 2 text goes here Location: Inglewood, CA School: Ben Franklin Elementary Grade: 4
So, basically, there are numerous delimiters (Question:, Location: School:, etc) and nothing that indicates the start of a new question. Note, I can't use : as a delimiter as it often appears in the text as a legitimate character
Can someone inform me on the best way to parse using multiple delimiters so it reads:
Question: Question Text
Location: Chicago, IL
School:
Grade: 8
Question: Question Text
Location: Inglewood, CA
School:
Grade: 4
thank you
- 04-18-2009, 11:26 PM #2
You'll need to just tokenize it and manually work through it. The delimiters you want to look for are "Question: ", "Location: ", etc.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-19-2009, 12:50 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
Also crossposted at New To Java - parsing multiple delimiters
- 04-19-2009, 12:51 AM #4
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Read file delimiters
By GraemeH in forum New To JavaReplies: 4Last Post: 03-29-2009, 11:44 AM -
Xml Parsing
By Nomad in forum XMLReplies: 12Last Post: 02-22-2009, 11:19 AM -
xml parsing
By gaurav65176 in forum XMLReplies: 5Last Post: 11-12-2008, 11:07 AM -
Extracting words from a string using delimiters
By toad in forum New To JavaReplies: 4Last Post: 07-07-2008, 01:32 PM -
Parsing URL
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks