Substring Function - Ignition's Expression language

Good Afternnoon.

According to the documentation: https://docs.inductiveautomation.com/display/DOC81/substring, the indexes (startIndex, endIndex) of the substring() function should start at zero. So, to get the substring “urge” inside the string “hamburger”, you would have to execute substring(“hamburger”, 4, 7), but you really have to execute substring(“hamburger”, 4, 8). Why?

The documentation says exactly: Substring will return the portion of the string from the startIndex to the endIndex, or end of the string if endIndex is not specified. All indexes start at 0.

Best Regards.

Because, well, Java.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring(int,int)

As with python slices, the beginning is inclusive, the end is exclusive.

Ok, but the Ignition’s documentation in this case is confusing.

Thank you.

The page https://docs.inductiveautomation.com/display/DOC81/substring has just been updated. It seems like I have a lot of influence on Ignition … hahaha

That, or you caught me in a good mood :slight_smile: