This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Parsing Headache - Please Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing Headache - Please Help" Watch "Parsing Headache - Please Help" New topic

Parsing Headache - Please Help

Chris Cairns
Ranch Hand

Joined: Jan 31, 2003
Posts: 48
Here's the problem. I need to cutoff any text to the right of and including the following words: "1CFP", "CFP", "1TNK", "TNK", "1AL1", "Al1", "1ATC", "ATC", "1WBL", "WBL", "1SHP", "SHP". (See full text below.) The constraint is that I cannot use methods or packages from Java 1.4, just 1.3. This means no regex and no strObj.split(param). (I used the latter successfully to cutoff the text, but then found out that it had to be compatible with version 1.3). I've tried a few approaches with no success. I must admit, my problem is with the logic. So I'm hoping that someone could give me some pointers. I'd really appreciate it.

[ April 08, 2003: Message edited by: Chris Cairns ]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Maybe something like this:

Here's the output:

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Chris Cairns
Ranch Hand

Joined: Jan 31, 2003
Posts: 48
I think what I can do is grab the character length of each row. If it's greater than 69, then I'll grab a substring from 0 to 69. If not, then don't grab a substring.
I agree. Here's the link:
subject: Parsing Headache - Please Help
It's not a secret anymore!