text between two "\"

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


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



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:

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

1 Like

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