What is the path to use the substring function?

In “appendix B” under “Strings”, there is a “substring” function. The syntax for it is as follows:

substring(“unhappy”, 2)
… returns “happy”

Unfortunately, I can’t just type "substring(“Unhappy”,2) into the script console. “Substring” is undefined.

What library do I need to reference/import to use the substring function? I have been searching for a while and can’t find any reference to it.

Thanks

You’re making a very common mistake - mixing up the expression language and the scripting language.

In the script playground you’re writing python code, none of the expression functions will work there.

Since in Jython, strings are treated as sequences with each character being an element, this is easily accomplished with:

strValue = "unhappy"
newValue = strValue[2:]
print newValue

newValue returns “happy”

See: https://docs.python.org/2.7/tutorial/introduction.html#strings

More on…Python substring