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:
London, UK
London,
,
And the results I want:
London, UK
London
[empty string]
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.
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.
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.