Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

Close
Important Announcement: WELCOME to the new Schneider Electric Community! Community is now no longer part of Exchange, and is now rebranded under se.com. If you have any bookmarks and links saved, we request you to update them to ensure that you continue accessing our community from this new location. For any issues that you might encounter as part of this change, please reach out to SchneiderCommunity.Support@se.com, and the team will help to get your issues resolved.
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
82536members
350141posts

Find the Last Position of a Character in a string

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

Solved
Tanquen
Lt. Commander
Lt. Commander
0 Likes
3
1163

Find the Last Position of a Character in a string

Trying to create a text animation expression that will give me all the characters after the last occurrence of a Space or particular character.

 

I've seen examples online that use in string reverse, Find, Trim and other commands that don't seem to be available. I think I've only got InString, Left, Mid, Right, Len etc.

 

I've tried nesting some Mid commands and it works but it's getting ugly fast.

 

MID( MID( MID( ".Name", INSTRING( ".Name", ' ' ),-1 ), INSTRING( MID( ".Name", INSTRING( ".Name", ' ' ),-1 ), ' ' ),-1 ), INSTRING( MID( MID( ".Name", INSTRING( ".Name", ' ' ),-1 ), INSTRING( MID( ".Name", INSTRING( ".Name", ' ' ),-1 ), ' ' ),-1 ), ' ' ),-1 )

 

Using the Right command also works but seems a little fragile. If there was an extra space in the last seven characters and or the end of the string that I want at some point is greater than seven characters it'll stop working.

 

MID( RIGHT( ".Name",7), INSTRING(RIGHT( ".Name",7), ' '), -1 )


Accepted Solutions
AdamWoodland
Commander Commander
Commander
0 Likes
2
1156

Re: Find the Last Position of a Character in a string

Check out ELEMENT(), specify a space as the splitter, index of 0 (or 1, can't remember which is the first index) and specify in reverse (i.e. last param is 1).

 

See the help for all the options on ELEMENT()

See Answer In Context

3 Replies 3
AdamWoodland
Commander Commander
Commander
0 Likes
2
1157

Re: Find the Last Position of a Character in a string

Check out ELEMENT(), specify a space as the splitter, index of 0 (or 1, can't remember which is the first index) and specify in reverse (i.e. last param is 1).

 

See the help for all the options on ELEMENT()

Tanquen
Lt. Commander
Lt. Commander
0 Likes
1
1151

Re: Find the Last Position of a Character in a string

Thanks!

 

That is much better. Too bad it's not on the same page in the manual as the String Functions. 

 

This works:

ELEMENT(1, ' ', ".Name", 1)

 

I had to search for "Element (" with quotes to find it. 

Tanquen
Lt. Commander
Lt. Commander
0 Likes
0
1053

Re: Find the Last Position of a Character in a string

Sort of on the same topic, is there a command that's the opposite of STR? I'm having some issues with parameter values not being processed by the expression in a way I'd expect. I have an object in the template that's looking at a parameter for its visibility and that works but if I take the same parameter and the visibility is a expression flowchart it no longer works unless I say parameter: tag1 =’1’. I can also get around it by saying “parameter: tag1 OR parameter: tag2”. But I can't use a flow chart expression to check if tag one is true and then if tag two is true and so on. I'm thinking it's because when I use the flowchart expression it's seeing the "parameter: tag1" as a string and not a value.

 

*****************

 

Looks like INT works.

INT(INTEGER or REAL)