This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to split the string in java  RSS feed

 
Mobio Dev
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi expert, i'm having string like Mr John Smith Dickson<john@aol.com>, i want to split it into 3 part
1st part - Mr
2nd part - John Smith Dickson
3rd part - john@aol.com

i'm confusing with the logic, i'm trying on that, how this can be done,

thanks in advance
 
Mohamed Sanaulla
Bartender
Posts: 3174
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can split the name and email address which are seperated by "<"- You will get an array of 2 elements- Name and Email(with a ">" at the end, you would have to delete it). Then in the first element- Name- You can split- using " " and then except the first element- You can concetenate the other elements of the array to get- "Mr" and "Full name".

You can use the split() method in the String API- http://download.oracle.com/javase/6/docs/api/java/lang/String.html

Let us know if you have any problem in implementing this. By the way- This is a crude way of doing it ;) , but it gets the work done.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!