Need Split(' ') to work with one OR MORE spaces

I have a string that's space delimited. But when there are two or more spaces between valid pieces of data, it's not working.

I need one, two, three or more spaces to be delimeters.

What call to Split() would handle this?

Thanks,
newbieweb
newbiewebSr. Software EngineerAsked:
Who is Participating?
 
magicdlfCommented:
           str.Split(new char{' '}, StringSplitOptions.RemoveEmptyEntries);
0
 
Ron MalmsteadInformation Services ManagerCommented:
The best way to handle that is to do a .replace("  "," ")... before the split, that way you are counting double spaces as a single delimiter.  You can do this without affecting the original string.
0
 
Ron MalmsteadInformation Services ManagerCommented:
In  vb.net, it might look something like this...
dim strtempvar as string = (stryourstring.tostring.replace("  "," ").tostring).tostring.split(" ").GetValue(0).tostring
0
 
newbiewebSr. Software EngineerAuthor Commented:
Yes, but then I need to loop to be sure al double spaces are replaced. Right?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.