# Substring Function - Ignition's Expression language

**URL:** <https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 8, 2021, 4:19pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065 "2021-01-08T16:19:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [January 8, 2021, 4:19pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065/1 "2021-01-08T16:19:57Z")

</div>

Good Afternnoon.

According to the documentation: [https://docs.inductiveautomation.com/display/DOC81/substring](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.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 8, 2021, 4:39pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065/3 "2021-01-08T16:39:41Z")

</div>

> [@informatica](#):
>
> Why?

Because, well, Java.  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring(int,int)](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.

---

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [January 8, 2021, 4:41pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065/4 "2021-01-08T16:41:36Z")

</div>

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

Thank you.

---

<div class="post-metadata">

**Author:** ![informatica](https://avatars.discourse-cdn.com/v4/letter/i/3ab097/32.png) [@informatica](https://forum.inductiveautomation.com/u/informatica)\
**Post date:** [January 8, 2021, 4:51pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065/5 "2021-01-08T16:51:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 8, 2021, 4:53pm UTC](https://forum.inductiveautomation.com/t/substring-function-ignitions-expression-language/42065/6 "2021-01-08T16:53:57Z")

</div>

That, or you caught me in a good mood 🙂
