06-27-2015 12:42 PM - edited 06-27-2015 12:58 PM
Hello i am getting a string input that sperates a data table with a random amount of spaces.
Is there a way to replace All space sequences with a single space ?
e.g.
CPU MEM PID
15.689 12.2 6610
21.8 156 6611
(so the spaces are random)
I have ried replaces double spaces with single spaces a total of 8 times in succsession but for some reason that is also removing (some) single spaes as well and im not sure why.
Solved! Go to Solution.
06-27-2015 01:13 PM
You can do this with a single Search and Replace String. You need to enable Regular Expressions for this function (right-click the function, choose Regular Expression). The Regular Expression " +" (space followed by a + sign) will match one or more spaces -- wire this into the Search String. Wire a single " " (space) into the Replace String, Set "Replace All" true, then run the function and it will replace all multiple spaces (in the current line) with a single space. If you want it to handle multiple lines in the string, enable that option as well.
Bob Schor
06-27-2015 01:25 PM - edited 06-27-2015 01:28 PM
"Scan string for tokens" by default treats multiple consecutive delimiters as one. That's what I would use here because it also eliminates the "spreadsheet string to array" you seem to be using later. Do it all at once!