String Manipulation impossible with "\" char

Hello,

I’m using URL to File Path to get Parent Folder.
let’s say it is.
c:\users\me\knime\files

I would like to convert it to go to root folder:
c:\users\me\knime

so I tried to do it via string manipulation with
lastIndexOfChar($Parent folder$, ’ \ ‘)1 but it returns a “invalid character constant”
I tried with lastIndexOfChar($Parent folder$, ’ \ "’)1 but it doesn’t give me the good position of the character (it returns -1)…
1 (without the space, but if I write it attached, it is not displayed on this forum…

How can I transform c:\users\me\knime\files to c:\users\me\knime ?
(this is to be used in a “Create File Name” node)

Thank you.

Hi,

I’m answering myself… this needs a second \ => \ \ that the knime will see as 1 \

so to get my root folder…
substr($Parent folder$,0,lastIndexOfChar($Parent folder$, ’ \ \ ')) [without space]

Thank you.

3 Likes

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