text between two "\"

dears,
I need to extratc the text EnergySavings from the string
\General Attributes, filled automatically\Part C\EnergySavings\EnergyType

I’m trying to use the function indexOfChar but I didn’t succeeded

thanks
Enrico

Hello @ecamerin
Have you tested Cell Splitter node; with ‘\’ as delimiter.

BR

2 Likes

Hi @ecamerin ,
you can succeed only if the text you’re trying to extract always follows the same pattern, e.g. it’s in the third position, it’s after “Part X/”, it contains “Savings” etc… And the pattern must identify that text uniquely, that is with no ambiguity.
“Cell Splitter” - as suggested by @gonhaddock - would be the right solution in the first case

1 Like

Hi @ecamerin and welcome to the Knime Community.

It’s not clear what you are trying to achieve.

I mean, if you want to extract some dynamic string that’s at a specific position, then you can use what has been suggested. If you need to extract “EnergySavings” from a string, then you just need to check if the string has it, and if it exists, then the extracted results will be… well “EnergySavings”…

To check if the string “EnergySavings” exists, you can use the IndexOf() instead of IndexOfChars(), like this:
indexOf($column1$, "EnergySavings")

When found, the IndexOf() will return the position where the string is.
If not found, IndexOf() will return -1:
image

You can then apply some rule to “extract” the “EnergySavings” text:
image

1 Like

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