• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Split... multiple spaces

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Probably has been asked many times ,but since the group doesnt a search feature (or maybe it has and i dont know about it) i think my quickest way out is to post it.

I need to split a string "This is my Red house".
remember string contains multiple spaces like 3 before Red and 4 before house to the following

This
is
my
Red
house

can someone show me the way out.
The String Tokenizer class dosent seem to have someting like this , i think String.split may have something but havent been able to find out..
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

Using String.split is good way to do this.


You will get array consisting of "This", "is", "my", "Red", "house". That " +" argument to split method means that delimeter is one or more spaces (it is regular expression).
[ May 18, 2005: Message edited by: Peter Stibrany ]
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bulls Eye !!!
Thanks Mate... that solved my problem!!

ADIOS
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As an aside, see http://faq.javaranch.com/view?SearchFirst for several tips on how to search this site.
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic