I’m trying to clean up some combined columns using String Manipulation or String Replacer but the Regex is not working as expected.
Here is my data:
And the results I want:
I would like to remove the ", " when it is at the end of the string.
The regex I am using:
regexReplace($Address Line 2$, “,\s$”, “”)
,\s$ works in online Regex websites like regex101 but in KNIME it isn’t changing the string at all.
I have also tried using the regex in String Replacer with the same results.
Can anyone help?
In KNIME you need to escape special characters, like the slash.
Regex101 can help you translate your code for this purpose. In the left hand menu under tools, click on Code Generator. Select Java and look for the contents of the
final String regex =. If you paste that in the RegexReplace, then it should work.
You will see that
Hope this helps!
Hi, I’m still not seeing a difference
Expression in String Manipulation:
Then your data input is probably slightly different.
[,]$ should also work if you don’t have an empty space behind it.
Test this String Manipulation’ node:
regexReplace($text$, "(.*)[,]$", "$1")
regexReplace(strip($text$), "(.*)[,]$", "$1")
Thank you both.
I managed to get it working.
For some reason Column Combiner was stripping the space in the delimiter, so my original Regex was not correct.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.