Forums Register Login

find string with whitespace in between

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
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
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1318 times.
Similar Threads
help with testing the last token
Java is lexical analysis
use of variables in awk to search for pattern from a file
Missing last entry in a text file
testing a stringtokenizer
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:44:48.