String manipulation using Regex

Hi
I am trying to remove {kg, mm, l, xl, mg} from the $Name$ column. My idea was to

  • using regex to capture all two chars which are bound between space or are at the end of the sentence:
    space xx space ==> “”
    space xx end of sentence ==> “”

my problem is regexReplace in string manipulation does not take $ as an end of the sentence. Moreover, I don’t know how should I define white space here.

I also was interested to filter them as below:
space (kg|mm|xl|mg) space ==> “”
space (kg|mm|xl|mg) end of sentence ==> “”
How should I define OR AND ?
Could you please help me to write the regular expression, If you share a link to learn more about how regular expiration work in knime would be really helpful.
Thanks in advance

Hi @Zeinab,

Would you provide a few examples of the input and your desired output please?

:blush:

Sure,
for example: one value of Article Name column is:
Doppelringschlüssel, Edelstahl, SW 19 x 22 mm ==> my desire output is to get ride of all sizes and scale info like:
Doppelringschlüssel, Edelstahl, SW

first I removed all numbers then after I tried to remove remaining parts in this case they are x and mm at the end of sentence. Sometimes these information are in the middle of the sentence, here you see the expression:

regexReplace(replaceChars(regexReplace(lowerCase($articleName$),"[0-9]" ,"" ),"-,/.:" ," " ),"( mm )|( m )|( x )|( xl )|( cm )", " " )

As you know it does not remove mm in the above value since it happen at the end. I wanted to put $ to define end of sentence but it does not work.

my idea is to remove all two chars which are bound between space:

space [a-z][a-z] space ==> “”
for example:
Doppelringschlüssel, SW 19 x 22 mm Edelstahl ==> Doppelringschlüssel, 19 x 22 Edelstahl

Thank you for your complete explanation. But please provide as many example as possible to show me all potential cases.
It would be great if you provide a data set with a few input and your desired output examples.

:blush:

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