| 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
|
|
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
|
 |
 |
|
|
subject: how to split the string in java
|
|
|