wood burning stoves 2.0*
The moose likes Java in General and the fly likes Getting substrings from a Java string without any whitecharacter problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Getting substrings from a Java string without any whitecharacter problems

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi all,
I have an address that is coming in the form of 2000-2345 S Campbell Avenue
I want to get three substrings : 2000
2345 and
S Campbell Avenue
Then I want to create 2000 S Campbell Avenue
and 2345 S Campbell Avenue
How can I do it ?
Any sample code,.. Please
Also the address can have a white character(space) between 2000 and - and 2345
ie, it can be 2000 - 2345 S Campbell Avenue
Any help.
Thanks,
Maya
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you use the StringTokenizer class and set the delimiters to a space and a hyphen, then check the token for numeric or alpha, you can concatenat the alpha tokens back together putting the spaces back in. The only problem might be if there was a hyphen in the alpha name of the street.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I see you got a working solution in Beginner. Please do not cross post.
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Cross Posting = false;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting substrings from a Java string without any whitecharacter problems