I suspect you could do this with regular expressions (java.util.regex.*).
There's a split() method in Pattern that will split a string around pattern
matches, but it looks like this is basically an advanced version of
StringTokenizer.  I think for your needs, you need a pattern along the lines
of /(\b\w+\b)|("[^"]+")/.   If you're not familiar with regex gibberish, I'm
attempting to creating a pattern that matches either of two things.  The
first looks for "word" characters (a-zA-Z) with "word boundaries" on either
side, OR (|), I look for any characters that are surrounded by double
quotes.  

K.C.

> -----Original Message-----
> From: Davor Cengija [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 22, 2002 2:25 AM
> To: [EMAIL PROTECTED]
> Subject: [Lang] StringUtils.split() with quoted strings
> 
> 
> Is there a method in StringUtils or some other utility class 
> which splits a 
> string into an array, but taking care of quoted substrings? 
> E.g., a string
> 
> This is "a quoted substring" and some "other text"
> 
> should be split to
> 
> This
> is
> a quoted substring
> and 
> some
> other text
> 
> StreamTokenizer does a good job with a single quote char, but 
> I'd like to 
> have multi-char word and substring separators.
> 
> If not, I might give it a try.
> 
> Cheers,
> Davor
> -- 
> [EMAIL PROTECTED]
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 

Reply via email to