# Regex not working - Why?

**URL:** <https://forum.knime.com/t/regex-not-working-why/24008>\
**Category:** KNIME Analytics Platform\
**Created:** [May 22, 2020, 11:13am UTC](https://forum.knime.com/t/regex-not-working-why/24008 "2020-05-22T11:13:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavin\_Attard](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gavin_attard/32/18047_2.png) [@Gavin\_Attard](https://forum.knime.com/u/Gavin_Attard)\
**Post date:** [May 22, 2020, 11:13am UTC](https://forum.knime.com/t/regex-not-working-why/24008/1 "2020-05-22T11:13:46Z")

</div>

HI Folks

I am using the regex below to repalce any emails found in a text string.

regexreplace($Verbatim$,"([\’\.\w-]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4})","-email-")

However Knime is returning the following error:  
‘Ambiguos return type…’  
i tried wrapping in a string() but it still failed.

Why does it not like it? This is a tried and tested regex string i have used before…

cheers

---

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 22, 2020, 11:21am UTC](https://forum.knime.com/t/regex-not-working-why/24008/2 "2020-05-22T11:21:21Z")

</div>

do you have an example string where this is happening? 🤔

---

<div class="post-metadata">

**Author:** ![Gavin\_Attard](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gavin_attard/32/18047_2.png) [@Gavin\_Attard](https://forum.knime.com/u/Gavin_Attard)\
**Post date:** [May 22, 2020, 11:21am UTC](https://forum.knime.com/t/regex-not-working-why/24008/3 "2020-05-22T11:21:35Z")

</div>

In typical fashion i resolved the issue by using the String Replacer tool, which worked on the standard regex pattern. Superb

Still curious as to why regexreplace in string manipulation is so fussy…

---

<div class="post-metadata">

**Author:** ![Gavin\_Attard](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gavin_attard/32/18047_2.png) [@Gavin\_Attard](https://forum.knime.com/u/Gavin_Attard)\
**Post date:** [May 22, 2020, 11:22am UTC](https://forum.knime.com/t/regex-not-working-why/24008/4 "2020-05-22T11:22:02Z")

</div>

it’s in the original post.

egexreplace($Verbatim$,"([\’.\w-]+)@((?:[\w-]+.)+)([a-zA-Z]{2,4})","-email-")

---

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 22, 2020, 11:23am UTC](https://forum.knime.com/t/regex-not-working-why/24008/5 "2020-05-22T11:23:19Z")

</div>

no what text is in the $Verbatim$ column (as well as the type of it - I guess string?)  
Or at least one string or example where i can get the error myself 🙂  
the regex looks fine so it should be something about the rest 😆

---

<div class="post-metadata">

**Author:** ![Gavin\_Attard](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gavin_attard/32/18047_2.png) [@Gavin\_Attard](https://forum.knime.com/u/Gavin_Attard)\
**Post date:** [May 22, 2020, 11:26am UTC](https://forum.knime.com/t/regex-not-working-why/24008/6 "2020-05-22T11:26:16Z")

</div>

it’s standard string text - verbatim responses from a survey  
the column type is set to string

---

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 22, 2020, 11:34am UTC](https://forum.knime.com/t/regex-not-working-why/24008/7 "2020-05-22T11:34:31Z")

</div>

ok i found your problem.  
You miswrote the regexreplace function.  
It should be “regexReplace” intead of “regexreplace”

\*also the correct regex would be (regex is correct but the \ have to be escaped - i think the string replace node does not need that)  
[\\’\.\\w-]+@(?:[\\w-]+\.)+[a-zA-Z]{2,4} \<-just noticed that the forum also thinks \ is the escape character - so maybe you already had the correct one :))  
 ![grafik](https://forum-cdn.knime.com/uploads/default/original/3X/a/e/ae5b403e9cb9b17b8075368be77d1a656f288dd3.png)

I think the color already tells you that something is wrong (not that it is stated somewhere 😛 :  
 ![grafik](https://forum-cdn.knime.com/uploads/default/original/3X/b/a/ba3a6a9d1e2d438ca7ff4059f56d646a7e1c1f74.png)

---

<div class="post-metadata">

**Author:** ![Gavin\_Attard](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gavin_attard/32/18047_2.png) [@Gavin\_Attard](https://forum.knime.com/u/Gavin_Attard)\
**Post date:** [May 22, 2020, 11:42am UTC](https://forum.knime.com/t/regex-not-working-why/24008/8 "2020-05-22T11:42:12Z")

</div>

🤬 🥴 🤪 🙏

---

<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 29, 2020, 11:42am UTC](https://forum.knime.com/t/regex-not-working-why/24008/9 "2020-05-29T11:42:16Z")

</div>

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