I want to add comma after every third character in the string data type, the length of this string will vary in each row,
For exp : 000XXX000000000000000000000000
000240240240210120120030XXX060060030XXXXXXXXX000000000
STDSTDSTDSTDSTDSTDSTDSTD
Expected result : 000,XXX,000,000,000,000,000,000,000,000
000,240,240,240,210,120,120,030,XXX,060,060,030,XXX,XXX,XXX,000,000,000
STD,STD,STD,STD,STD,STD,STD,STD
Hi @Sanket_1996 and welcome to the KNIME community
Please find below a generic solution based on the regex operator in the -String Manipulation- node:
replace( strip( regexReplace($Text$, join(".{", string( $${IPeriod}$$),"}"), "$0 ")), " ", $${SCharacter}$$)
A simplified version just answering your question “Comma every 3 characters” would be as follows:
replace( strip( regexReplace( $Text$, ".{3}", "$0 ")), " ", $${SCharacter}$$)
The workflow can be downloaded from here:
20220823 Pikairos How to Intercalate a set of Characters after every N Characters in String.knwf (29.6 KB)
Hope it helps.
Best,
Ael
3 Likes
system
Closed
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.