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?

newbiewebSr. Software EngineerAsked:
Who is Participating?
           str.Split(new char{' '}, StringSplitOptions.RemoveEmptyEntries);
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.
Ron MalmsteadInformation Services ManagerCommented:
In, it might look something like this...
dim strtempvar as string = (stryourstring.tostring.replace("  "," ").tostring).tostring.split(" ").GetValue(0).tostring
newbiewebSr. Software EngineerAuthor Commented:
Yes, but then I need to loop to be sure al double spaces are replaced. Right?
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.