Forums Register Login

Java Strings Getting a Substring

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).]
+Pie Number of slices to send: Send
Hi Kyle,
Thanks a ton for the code.
It works perfectly.
I shall add the checking for NullPointer later.
Thanks again,
Maya
Get out of my mind! Look! A tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1181 times.
Similar Threads
conversion of String object to integer primitive
Setting a value in an XML
JSP / XML question
Getting substrings from a Java string without any whitecharacter problems
Address validation : help needed
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:46:30.