Replace substrings within two fixed strings - Regex used

Hello all,

I have the a cell in a column with the following strings:

col0
color: 2A6738-9 size: 12

Using the String Manipulation node, I can manage to match this cell above w the following expression, however, if I want to change the words, “color” and/or “size”, if I do use the expression below, I end up w only "size: ". I lose everything else. The reason I would need to ‘match’ w regex, is basically because I have can have other variations of “color” and “size” throughout the rest of the column below.

regexReplace($col0$,"(color: )+(\\S+)+(\\s+)+(size: )+(\\d+)","size: ")

Is there a way to simply match the regexes and if it does match it, replace “color” OR “size” with x OR y but keep whatever else is NOT specified in the replace attribute variable?

Thanks,
J.

Hi @jarviscampbell , I’m not sure what you are trying to do.

Can you show what the expected results should be for your sample data? Perhaps give more sample data with expected results.

Your expression will indeed replace everything with "size: ". It’s what you are telling it to do.

Examples of this too will be helpful and what the results you want for this.

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