Very special string manipulation

Hi to all,

I have a very special problem with string manipulation. I read text files from control units. In this textfiles there are HEX dumps as strings and I have to manipulate these string in a very special way. This is for example:

hex string read: 01F5FEF5F8F5…
convert to: 0x01 0xF5 0xFE 0xF5 0xF8 0xF5…

My frist problem is to “strip” the string every second char or “loop” through the string. If this is done the further steps can be don with a simple Replace. But the space every second char?
Every string is stored in a row or rather in a cell.

Has anybody an idea how to handle this?

Greetings,
brotfahrer

1 Like

Hi there @Brotfahrer,

have you checked Cell Splitter By Position node? There you can configure to do split on every second char. Once done use Column Combiner on all new columns with space as delimiter. To get wanted format use following syntax in String Manipulation node:
join ("0x", replace ($combined string$, " " , " 0x" ) )

Br,
Ivan

3 Likes

Hi,
you can also do it in the String Manipulation node directly using regular expressions:

strip(regexReplace($yourcolumn$, "[0-9A-Z]{2}", " 0x$0"))

“[0-9A-Z]{2}” means that either a number or an uppercase character has to occur 2 times for a match. In the replacement, $0 stands for the matched portion of your string. Finally I apply strip() to remove the leading whitespace introduced by the replacement.
Kind regards
Alexander

5 Likes

Hi Alexander,

thank you for your solution it works perfect! Awesome!

Regards
brotfahrer

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.