Getting string data from tag path dynamically

I am looking to get part of my path name dynamically into a memory tag:

My path: Area/LSD/Well/tagname

If i use: left({PathToParentFolder},lastIndexOf({PathToParentFolder},"/"))
I can get back : Area/LSD/Well/

Or If i use: left({PathToParentFolder},IndexOf({PathToParentFolder},"/"))
I can get back : Area

But the one i need is: LSD
i cant use a dedicated number for the index, because the Area name will change and the name length will differ. any one have any ideas how i could accomplish this?

Thank you in advance…

Edit: I am using this in an ‘Expression’ memory tag in a UDT

Have you thought about using split()? Something like:

split({PathToParentFolder},'/')[1,0]

I can’t test it right now but split returns a dataset which I believe would be one column, you want row 1 to get LSD.

1 Like

Yes, returns one Column named parts.

If you want to only remove the Area part of the path, you can also use the split with a limit, something like

split({PathToParentFolder},'/',2)[1,0]

In this case, row 0 would be Area, and row 1 would be LSD/Well/tagname

1 Like

Thank you guys… split({PathToParentFolder},’/’)[1,0]
Worked perfect…