Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

andrewheard

macrumors regular
Original poster
May 16, 2005
166
0
Ontario, Canada
Hi,
I need to be able to split a string into individual characters. Currently I have accomplished this using SINstring = target.split(" ");
and I have to enter the SIN as "1 2 3 4 5 6 7 8 9" but how can I have it so that I can input "123456789". Splitting it by any number with \d causes it to output nothing into the array because the delimiter gets removed and since all of them are numbers they go bye bye.

Thanks for any input,

Andrew
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
How about this:-

String[] s = test.replaceAll( "(\\w)", "*$1" ).split( "\\s*\\*\\s*" ) ;

This will, I think, handle strings with arbitrary spaces like "12 3 45 678 9"

b e n
 

andrewheard

macrumors regular
Original poster
May 16, 2005
166
0
Ontario, Canada
Thanks for the replies and sorry for the delayed response. I ended up writing the thing so i didnt't even have to split the String. Don't know how to explain it but it works.

Thanks again,

Andrew
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.