Variable substring in a string


I need your help in the following example:

Is in use TXW_yello in colour
For this TXW_red not used
Using TXW_green is highlighted
For this TXW_black is too dark
For using TXW_magenta runs out

I need only the colour names which stands on different positions in the text. Only the letters “TXW_” are every time before the color name.

Has anyone an idea?

Best regards,

Hello @juergen01,

I suggest using regex here. This one works in Regex Split node but maybe there is a better one :wink:
.*TXW_([a-zA-Z]+) .*


1 Like

Hi @ipazin,

Thanks for your fast reply. Regex Split says that the input sting did not match the pattern or contained more groups than expected.

Hi @juergen01

what happens if you put the regex syntax into brackets?

(.*TXW_([a-zA-Z]+) .*)


Hi @morpheus,

the warning is the same as before. Two new columns are empty.

Best regards,

Hi Jürgen,
i tested your example and this works as expected.

Example Example2


1 Like

Hi @morpheus,

the problem maybe is that the real data contains also numbers which I added in our expression (.TXW_([0-9a-zA-Z]+) .). The real data is more complex and looks like

file /usr/abc/TV1/partner/data1/text/views/124116TXW_BLACK is too dark

I thought I could could shorten my example.


You should be able to get it like that


Hello all,

the idea behind using Regex Split in this and similar use cases is to only extract part of string/information you need without rest of it in additional columns. To achieve it you only put into brackets what you want to extract. So brackets around .* or entire expression are redundant.

@juergen01 here is workflow example where you can see that regex from my above reply works just fine on input data you provided. (Problem is not in numbers as text (color name) after TXW_ string doesn’t contain numbers).
2020_10_20_RegexExample.knwf (11.1 KB)


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