• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find string with whitespace in between

 
James Byars
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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

 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic