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 / August 2005

Tip: Looking for answers? Try searching our database.

Strings

Thread view: 
Masamunexiii - 11 Aug 2005 06:10 GMT
How do you break apart strings? For example the user type in John, Doe
E. and you want put John in one variable, Doe in another and E in the
third? I looked through any java books i found and it did not mention
this?
Tonton - 11 Aug 2005 06:26 GMT
"Masamunexiii"
> How do you break apart strings? For example the user type in John, Doe
> E. and you want put John in one variable, Doe in another and E in the
> third? I looked through any java books i found and it did not mention
> this?

You might find a neat solution using  String[] String.split (String regex)

You might need to learn things about "regular-expressions"
Hal Rosser - 11 Aug 2005 22:01 GMT
> How do you break apart strings? For example the user type in John, Doe
> E. and you want put John in one variable, Doe in another and E in the
> third? I looked through any java books i found and it did not mention
> this?

Look at the split method of the String class - and also take a look at the
StringTokenizer class.
Rivky - 12 Aug 2005 15:11 GMT
You should also look at the String substing method. You can do
string.indexOf(" "); to find the index of the delimiter (maybe a space
in this case?) and the use the substring methid to grab data you want.
Hal Rosser - 13 Aug 2005 05:58 GMT
yeah - funny thing about java. more than one way to do it.
(Like Perl - or M$ dot-net- or Python - or PHP or <insert language here>)

> You should also look at the String substing method. You can do
> string.indexOf(" "); to find the index of the delimiter (maybe a space
> in this case?) and the use the substring methid to grab data you want.


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



©2008 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.