Hi. Suppose I have a string "cat,dog,,,,mouse,". Is there a simple way to break this string into a list of substrings in such a way that the result is {"cat", "dog", "", "", "", "mouse", ""}? I've been using the Words() function, but it seems to treat consecutive delimiters in series as just one:
//Desired list result should be {"cat", "dog", "", "", "", "","mouse", ""}<BR /><BR />Names Default to Here(1);
str = "cat,dog,,,,mouse,";
lis = Words(str, ","); //This returns {"cat", "dog", "mouse"}I tried to format the string ahead of time using Substitute:
newstr = Substitute(str, ",,", ", ,"); //Returns "cat,dog, ,, ,mouse," <BR />lis = Words(newstr, ","); //Returns {"cat", "dog", " ", " ", "mouse"}.<BR />finalis = Substitute(lis, " ", ""); //Returns {"cat", "dog", "", "", "mouse"} Note that there are still 2 consecutive delimiters between dog and mouse after the first Substitute() command. Thus, following the Words() function, one of the empty items between dog and mouse is still missing. Also note that the empty item at the end of the string is missing from the list.
Does anyone know of a way to do this, preferably one that does not involve a for loop?