Regular Expression for Whole Word Selection in Regexmatcher at String Manipulation Node

Hi @cschmid , welcome to the KNIME forum.

The word boundaries are, as you said, “\b” in regex, but to work with String Manipulator you will hit problems if you don’t “escape” the “\” in the string, so for each \b, you need to place an extra “\” in front:

try this:

regexMatcher($Institution$,join( "(?i).*\\b" ,$City$ ,"\\b.*" ) )

btw, when posting the code, to ensure that the forum doesn’t convert the double quotes in the code into “smart quotes” (and also have it display every \ correctly, highlight the code and click the “preformatted text” button on the forum message toolbar
i.e. image

see also

1 Like