# String Manipulation regular expression syntax for a fuzzy match

**URL:** <https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632>\
**Category:** KNIME Analytics Platform\
**Tags:** regex\
**Created:** [April 29, 2021, 8:36pm UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632 "2021-04-29T20:36:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMH829](https://forum-cdn.knime.com/user_avatar/forum.knime.com/jmh829/32/21629_2.png) [@JMH829](https://forum.knime.com/u/JMH829)\
**Post date:** [April 29, 2021, 8:36pm UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/1 "2021-04-29T20:36:58Z")

</div>

I am getting stuck on using regular expressions in the String Manipulation node. This will be example of text analysis for new KNIME users. My limitation is that I need to use a standard KNIME node and not a language snippet, a Palladian node, or something similar.

The main idea is to detect “password,” “passcode,” or a similar term such as “passwd,” “passwrod,” or “pass code,” while excluding terms such as “passkey,” "pass " or “unsurpassed.” On [https://regex101.com](https://regex101.com), I constructed this regex code that does exactly what I need by using the Java 8 flavor of Regex:

(\b)pass[]?[word]{2,4}(\b)|(\b)pass[]{0,1}[code]{2,4}(\b)

In the String Manipulator node in KNIME, my current configuration has this expression to match:

regexMatcher($Full Description$,  
“._\bpass[]?[word]{2,4}(\b)|(\b)pass[]{0,1}[code]{2,4}\b._”)

I have tried different variations such as with/without .\* and with/without parentheses around \b . My sample data set contains plenty of “password” and “passcode” string matches, but I only get False matches in the output table. What am I missing?

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![elsamuel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/e/b4bc9f/32.png) [@elsamuel](https://forum.knime.com/u/elsamuel)\
**Post date:** [April 29, 2021, 8:54pm UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/2 "2021-04-29T20:54:06Z")

</div>

I broke down your regex string piece by piece, then put it back together. I got the desired result using:

`regexMatcher($column1$,"pass[]?[word]{2,4}|pass[]{0,1}[code]{2,4}")`

![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/d/ede20b6617374398eb55f7988aebe7e513e9da4a.png)

---

<div class="post-metadata">

**Author:** ![JMH829](https://forum-cdn.knime.com/user_avatar/forum.knime.com/jmh829/32/21629_2.png) [@JMH829](https://forum.knime.com/u/JMH829)\
**Post date:** [April 29, 2021, 8:57pm UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/3 "2021-04-29T20:57:27Z")

</div>

Thanks! I neglected to mention that the terms are embedded in longer sentences, such as “I need to reset my password” and “Please change the pass code to the office door.” I tried your solution, but it did not work on the longer phrases.

---

<div class="post-metadata">

**Author:** ![G47\_2](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@G47\_2](https://forum.knime.com/u/G47_2)\
**Post date:** [April 29, 2021, 10:21pm UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/4 "2021-04-29T22:21:50Z")

</div>

Basically you only need to add wildcards to elsamuel’s solution:

![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/e/1eb7fc84beb619767af55d45bda6961b05d868ef.png)

NB: word boundaries in String Manipulation nodes need to come with an additional backslash. If I had only used \b instead of \\b, I would have gotten False in every row.

---

<div class="post-metadata">

**Author:** ![JMH829](https://forum-cdn.knime.com/user_avatar/forum.knime.com/jmh829/32/21629_2.png) [@JMH829](https://forum.knime.com/u/JMH829)\
**Post date:** [April 30, 2021, 10:56am UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/5 "2021-04-30T10:56:24Z")

</div>

Thank you to @G47_2 and @elsamuel ! The double backslash and additional parentheses solved the problem.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [May 7, 2021, 10:57am UTC](https://forum.knime.com/t/string-manipulation-regular-expression-syntax-for-a-fuzzy-match/32632/6 "2021-05-07T10:57:04Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
