String Manipulation RegexReplace - non-capturing group


using the following string manipulation function

regexReplace("with me, in a meeting",  "me(?:,)", "")


I get as I result: with  in a meeting

But I should get: with , in a meeting

because the comma "," is in a non capturing group.

How to ignore the comma and to get as a result:   with , in a meeting  ?

Thank in advance


Not much of KNIME related question, but I believe you are mixing up regex matching with capturing.

(?:,) will match anyway the comma, but will not capture it.

Since regex replacement usually replaces what is matched, not what is captured, your call matches "me," and replaces it with an empty string.

Either you avoid matching the comma altogether, or you still match it but replace it with another comma, like in this call:

regexReplace("with me, in a meeting",  "me(?:,)", ",")

Hope this helps.



Hi Marco,

thank you very much for your answer. The reason why it doesn't work now is clear .

But the solution is not completelly appropriate as, unfortunatelly, mine is only an example and my real goal is to ignore in the replacement a lot of possible things written in the non capturing group (e.g, commas, semicolumns, dots, other specific words etc.).

It would be nice to have the option in Knime to ignore non capturing group in the replacement.

May be there is another way to achieve this goal?

Thank you!

You can lookahead instead of non-capturing group:

Understood. Did you look into the Text Processing nodes part of KNIME Labs? They might be be a better fit to what you are trying to achieve, which seems to me more like advanced text pre-processing and analysis. See for example the Dict Replacer node.


Thank you Marco and Aborg.

Aborg, your solution works perfectly.

Many Thanks