Regex not working - Why?

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

do you have an example string where this is happening? :thinking:

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…

it’s in the original post.

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

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 :slight_smile:
the regex looks fine so it should be something about the rest :laughing:

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

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

I think the color already tells you that something is wrong (not that it is stated somewhere :stuck_out_tongue: :
grafik

5 Likes

:face_with_symbols_over_mouth: :woozy_face: :crazy_face: :pray:

2 Likes

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