How do we add a whitespace within the string in one of lists of which specific character length bigger than standard form?For an example;
Character Column#1 at row#1: asd 123 deg jkldjsakldjlk 1124
if length of any of word within the cell value is bigger than "5", I want a whitespace on the third character.
Ideal form is as below
Character Column#1 at row#1: asd 123 deg jkl djsakldjlk 1124
thanks,
Data TableScriptingRe: How do we add a whitespace within the string in one of lists of which specific character length bigger than standard form?One way would be to use Regex.
This might work:
Names Default To Here(1);
line = "asd 123 deg jkldjsakldjlk 1124";
span_line = Regex(line, "([a-zA-Z0-9]{3})([a-zA-Z0-9]{3,})", "\1 \2", GLOBALREPLACE);
show(span_line == "asd 123 deg jkl djsakldjlk 1124");
line = "1 22 333 4444 55555 666666 7777777 88888888 999999999 0000000000";
span_line = Regex(line, "([a-zA-Z0-9]{3})([a-zA-Z0-9]{3,})", "\1 \2", GLOBALREPLACE);
show(span_line);https://regex101.com/r/CuxFKx/1
Re: How do we add a whitespace within the string in one of lists of which specific character length bigger than standard form?Here is one way of doing what you want
Names Default To Here( 1 );
dt = Current Data Table();
For Each Row(
holdString = "";
wordNum = 1;
While( Word( wordNum, :column 1, " " ) != "",
theWord = Word( wordNum, :column 1, " " );
If( Length( theWord ) > 5,
theWord = Substr( theWord, 1, 3 ) || " " || Substr( theWord, 4 )
);
holdString = holdString || " " || theWord;
wordNum++;
);
:Column 1 = Trim( holdString );