wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java Strings Getting a Substring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Strings Getting a Substring " Watch "Java Strings Getting a Substring " New topic
Author

Java Strings Getting a Substring

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 space between 2000 and - and 2345
ie, it can be 2000 - 2345 S Campbell Avenue
Any help.
Thanks,
Maya
kyle amburn
Ranch Hand

Joined: Jul 29, 2001
Posts: 64
Hi-
The following code will produce a string in the form of "number street and number street".

Kyle
P.S. The previous code does not have any error checking. i.e. (if there is not a - then you will get a NullPointerException). You should add error checking code to make this usable beyond a test stage.
[This message has been edited by kyle amburn (edited August 21, 2001).]
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi Kyle,
Thanks a ton for the code.
It works perfectly.
I shall add the checking for NullPointer later.
Thanks again,
Maya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Strings Getting a Substring