aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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://aspose.com/file-tools
 
subject: how to split the string in java