• 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

find string with whitespace in between

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I have a string that is separated by a delimeter -. I want to basically extract all the values from this string, and check if there is any whitespace between the values.

e.g.

if my string is
hello-world- this - is-me

the values would be
hello
world
this
is
me

and if the string is
hello world- bye-world-hello again world

then the values would be
hello world
bye
world
hello again world

as you can see, in the second example two of the values "hello world", and "hello again world" are separated by whitespaces, and I need to find such values.

thanks

thanks

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok first you want to split your string by the dash delimiter. Piece of cake.


As for whitespaces, you'll need to use a regular expression which is '\s'

Check here for reference http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/package-summary.html
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic