This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to split the string in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "how to split the string in java" Watch "how to split the string in java" New topic
Author

how to split the string in java

Mobio Dev
Greenhorn

Joined: Nov 03, 2010
Posts: 6
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

Joined: Sep 08, 2007
Posts: 2927
    
  15

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.


Mohamed Sanaulla | My Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to split the string in java
 
Similar Threads
Regular Expression
Regex for Reversing Last Name, First Name?
How to do regex searches / matches data from external file
Have you interviewed with SAIC?
SCJP but no experience