Hi Everyone.
I tried to create a string manipulation for knime that replace the 4th last space of my string with the expression “xxx” however it didn’t work.
Do you have a solution for this or an idea what I did wrong?
regexReplace($column1$, “(.?\s)(?:(?:.?\s){3})(.*)”, “$1 x xx $2”)
A couple of quick tips: when you repost you regex expression, it is best to highlight it and press the </> (preformatted text) button on the toolbar
That way the forum software won’t try to interpret/modify the expression and we’ll be able to see and test exactly what you have written.
Also it is useful to share sample data and expected output as well as writing the description, to ensure our interpretation of what is being asked is correct.
Hello @miriamgurk and welcome to the KNIME community.
It isn’t fully clear to me your challenge. From description I can assume that your text string has always four spaces, aiming to replace the fourth of them with xxx
You can test with the following code:
regexReplace($text$, "(.*)\\s(.*)", "$1***$2")
Otherwise, can you provide a text sample and expected output?
As per @gonhaddock’s comment, after posting I realised that I wasn’t quite sure what is supposed to happen if you have several spaces in succession e.g.
This string contains many consecutive spaces
and I also handled only space, and not other “whitespace”, so again you may need to be more specific for these “edge” cases.