Column Row edit / change character - delete “../”

Hi!

I searched, but I couldn’t find the solution I wanted. As you can see, I want to delete or remove this characters:

“D:\KNIME_0347_Bitterfeld\DART\2016\034716TXW_” at the beginning of the field:

image

I have tried with the regexreplace function in String Manipulation, but nothing happens:

`

I’m new in Knime and I’m spending hours on this issue…

Do you have any suggestion?

Thanks for your help!

Robert

1 Like

hi @bermq and Welcome to the KNIME world,

regex replace is used for patterns rather than fixed search strings.
Instead, you may simply use the replace function for your use case.
However, you have to transform the search string for __.

Please try this formula…
replace($Extracted View$, "D:\\KNIME_0347_Bitterfeld\\DART\\2016\\034716TXW_", "")

Hope, this helps, Greetz, Tommy

1 Like

also @bermq the problem in your regex is that \ is an escape character in a regex expression.
To actually check for \ as a character you need to escape the special character so \

Also can be seen with a regex tester e.g.



so
D:\\KNIME_0347_Bitterfeld\\DART\\2016\\034716TXW_

should work

*however it seems like it still does not work in the string manipulation node :frowning:
With the string replacer it does work…not quite sure why there is an illegal escape sequence error in the string manipulation node for this :thinking:
But with the normal String Replacer is works - strange

but as @tommy said if you just want to replace a fixed string replace is what you want (as regex is way slower then a simple replace in the execution)

3 Likes

Dear Tommy and AnotherFraudUser,
Many, many, many thanks for the quick reply.
I see the problem was the character “”, I would never solved it in my whole life :smile:
A last question about this: if I wanted to delete all the characters before “_”, how could I do it?

1 Like

Sorry, I should delete all the characters before “W_”

I’m trying with the Regex split using this expression:

^[^]*(.*)$

but the output is:

“Bitterfeld\DART\2016\034716TXW_ACCDET.sap”

And it should be:

“ACCDET.sap”

Hi @bermq

if you want to use the split node
^.{0,}W_(.{1,})$ should work

so translated
^=beginning of string
.=any character (expect new line)
{0,}=repeated 0 or more times
W_=followed by W_
(.{1,})=followed by any character repeated 1 or more times -> save as matching group the () are for that
$=end of string

it will only return a string if all requirements above are met and return each matching group as a new column

If you want to use the string replacer node (regex mode and match whole string)
Search string ^.*W_
ReplaceBy “”

1 Like

Dear AnotherFraudUser,

Many thanks for the solution and the related perfect explenation!

1 Like

Hello!

@bermq next time ask sooner and don’t spend hours! Welcome to KNIME Community :wink:

Br,
Ivan

2 Likes

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