Basic string parsing/splitting question.

Subject: Basic string parsing/splitting question.
From: "Stoaks, Max" <Stoaks_Max@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Jun 2004 13:57:28 -0700
Sorry for this basic question...

I have a comma delimited list of tokens in a string that I want to get the first three from (if there are more than three). Else just the first one or two.

I.e. Given this string:
"Dogs, Big Sheep, Little Mice, Ants, Pelicans"

I'd like the result to be:
"Dogs, Big Sheep, Little Mice ..." 

Given:
"Dogs, Big Sheep, Little Mice"
It should just say:
"Dogs, Big Sheep, Little Mice"

Ditto for shorter ones.

Seems like there should be a function to split after the third occurrence of ",", but I don't find that anywhere.

Meanwhile, I'm looking at the EXSLT extensions to see if I can use a tokenizer or something like that.

Any help would be appreciated.

I'm using XalanJ 2.6.

Thanx,
Max

Current Thread