Need help to parse text files.
I am learning Java and need some assistance.
I'm trying to make a program that can scrape some data out of a text file and get certain important parts. The text files contains the source code for an ebay auction. What I am trying to do is grab key parts like the price, item location, etc.
I can get the source code and save it to a file and I can read and write files. What I need to figure out is how to grab that particular part of the file.
I know that I can use regular expressions to match things that I'm looking for, but how can I grab a part of the file that is after the match to the regex? I was able to match a line in the file that has the particular piece of info I want and store that in a separate string, but the line is quite long and I'm not sure how to break it down to get at what I need, or handle a situation where the rest of the information is on the next line.
Ideally I would like to get whatever is left on the line after the regex match, and then do a string tokenizer with a space delimiter which should capture the data and I can have it end when it reaches something like a < or "
I suppose I could take a whole line and tokenize it but there has to be a better way. Any assistance is appreciated.
Re: Need help to parse text files.
Hi,
You can use StringTokenizer or split method.
Re: Need help to parse text files.
Remember that if you use regex it tells you the index. If you use that index you can find what is after it (looking at the end of the index forward) or before the index (look at the beginning index backwards)