StringTokenizer supports multiple delimiters.  The constructor from the Java
Docs:
-----------------------------------------------
public StringTokenizer(String str,
                                String delim,
                                boolean returnDelims)
Constructs a string tokenizer for the specified string. All characters in
the delim argument are the delimiters for separating tokens.

If the returnDelims flag is true, then the delimiter characters are also
returned as tokens. Each delimiter is returned as a string of length one. If
the flag is false, the delimiter characters are skipped and only serve as
separators between tokens.

Parameters:
str - a string to be parsed.
delim - the delimiters.
returnDelims - flag indicating whether to return the delimiters as tokens.
---------------------------------------------------

StringTokenizer also returns the actual tokens (which is the characters
between the delimiters).

Do I misunderstand your question?  StringTokenizer will pull a chunk of text
out of a string when it is delimited by characters the program specifies and
return it to you as a string.  As you can see you can return the delimiters
themselves as tokens if you need to know which delimiters you hit.


 From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of McKain, James (DPYUS)
Sent: Monday, October 01, 2001 11:07 AM
To: [EMAIL PROTECTED]
Subject: [JSP-INTEREST] multiple delims...


I am trying to take a line of text from a StringBuffer object and pull out a
chunk of text from it.  I has investingated the StringTokenizer, but this
sorts with only one delim.  also, Tokenizer cannot return me the location
#(on the line) of the tokens.  only the amount of them.
question...
what can I use to return 2 delimeters, and the locations of both?
essentially I want the characters between the two tokens.
James McKain
800.473.3789 x2013
Contract Support Engineer
   lDePuy Orthopaedics, Inc.
                           a Johnson & Johnson  Company

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to