Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / July 2005

Tip: Looking for answers? Try searching our database.

Newbie: neither stringtokenizer nor split()

Thread view: 
Gin - 08 Jul 2005 22:33 GMT
I am looking for a way that will allow me to tokenize a string
describing the delimiter with a regular expression and that will also
return the delimiter in the token.

And i think Stringtokenizer can't take regex and split just won't
return the delim. So... here's where i get lost.

Thanks!!
Nathan Gilbert - 08 Jul 2005 22:43 GMT
> I am looking for a way that will allow me to tokenize a string
> describing the delimiter with a regular expression and that will also
[quoted text clipped - 4 lines]
>
> Thanks!!

If you are wanting the tokenizer to return the delimiters as tokens,
then when declaring your tokenizer make sure the third argument is true.

For example:

String Tokenizer st = new StringTokenizer("This|is|a|test","|",true);

NG
Signature

The life of a repoman is always intense!

Gin - 09 Jul 2005 11:21 GMT
Oh thanks but then the delimiter the second argument can't be a regular
expresssion.

The method I am looking for would be like the stringtokenizer but
taking regular expressions.

StringTokenizer syllable = new StringTokenizer("longevity",
"[^AEIOUYWaeiouyw][AEIOUYWaeiouyw]", true);

This regular expressions searches for syllables of one consonant and
one vowel.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.