# What is the path to use the substring function?

**URL:** <https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255>\
**Category:** Ignition\
**Created:** [October 18, 2016, 11:53pm UTC](https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255 "2016-10-18T23:53:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifejustice2](https://avatars.discourse-cdn.com/v4/letter/l/779978/32.png) [@lifejustice2](https://forum.inductiveautomation.com/u/lifejustice2)\
**Post date:** [October 18, 2016, 11:53pm UTC](https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255/1 "2016-10-18T23:53:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 19, 2016, 12:09am UTC](https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255/2 "2016-10-19T00:09:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [October 19, 2016, 2:09pm UTC](https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255/3 "2016-10-19T14:09:26Z")

</div>

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

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

newValue returns “happy”

See: [https://docs.python.org/2.7/tutorial/introduction.html#strings](https://docs.python.org/2.7/tutorial/introduction.html#strings)

---

<div class="post-metadata">

**Author:** ![walshmergak](https://avatars.discourse-cdn.com/v4/letter/w/46a35a/32.png) [@walshmergak](https://forum.inductiveautomation.com/u/walshmergak)\
**Post date:** [May 11, 2020, 5:15am UTC](https://forum.inductiveautomation.com/t/what-is-the-path-to-use-the-substring-function/12255/4 "2020-05-11T05:15:56Z")

</div>

More on…[Python substring](http://net-informations.com/python/basics/substring.htm)
