AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strings

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Masamunexiii
Guest





PostPosted: Thu Aug 11, 2005 5:10 am    Post subject: Strings Reply with quote



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?

Back to top
Tonton
Guest





PostPosted: Thu Aug 11, 2005 5:26 am    Post subject: Re: Strings Reply with quote




"Masamunexiii"
Quote:
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"



Back to top
Hal Rosser
Guest





PostPosted: Thu Aug 11, 2005 9:01 pm    Post subject: Re: Strings Reply with quote




"Masamunexiii" <jkamdar (AT) wideopenwest (DOT) com> wrote

Quote:
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.



Back to top
Rivky
Guest





PostPosted: Fri Aug 12, 2005 2:11 pm    Post subject: Re: Strings Reply with quote

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.

Back to top
Hal Rosser
Guest





PostPosted: Sat Aug 13, 2005 4:58 am    Post subject: Re: Strings Reply with quote

yeah - funny thing about java. more than one way to do it.
(Like Perl - or Microsoft dot-net- or Python - or PHP or <insert language here>)

"Rivky" <rasapir81 (AT) aol (DOT) com> wrote

Quote:
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.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.