• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Strings Getting a Substring

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kyle,
Thanks a ton for the code.
It works perfectly.
I shall add the checking for NullPointer later.
Thanks again,
Maya
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic