wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes How to use Scanner and reg exp to break up string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to use Scanner and reg exp to break up string" Watch "How to use Scanner and reg exp to break up string" New topic
Author

How to use Scanner and reg exp to break up string

Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
I am trying to use Scanner to break up a string that i read in from file.
File data is:


The steps i need to do are:
Get length from :28 to </n0:message>
Prefix this length to before :28 and get rid of the rest

is there a regular expression i can call to get string token from :28 to </n0:message>?
So far i have a delimiter to get string token from :28 but i dont know how to stop at </n0:message>.


This allows me to include the delimiter which i want, but if i wanted to try and include the delimiter but at the end of the token instead of the start how can i achieve this.



If i run this my data will be like:


All i want from my raw data is three tokens:


I hope i havent made this too confusing!

Thanks,
Shane.

Shane Lee
Ranch Hand

Joined: Mar 19, 2005
Posts: 63
This seems to work.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use Scanner and reg exp to break up string