# Help manipulating strings in expressions or scripts

**URL:** <https://forum.inductiveautomation.com/t/help-manipulating-strings-in-expressions-or-scripts/55777>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [February 4, 2022, 6:42pm UTC](https://forum.inductiveautomation.com/t/help-manipulating-strings-in-expressions-or-scripts/55777 "2022-02-04T18:42:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle\_fineran](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kyle\_fineran](https://forum.inductiveautomation.com/u/kyle_fineran)\
**Post date:** [February 4, 2022, 6:42pm UTC](https://forum.inductiveautomation.com/t/help-manipulating-strings-in-expressions-or-scripts/55777/1 "2022-02-04T18:42:44Z")

</div>

I am using a horizontal menu to navigate between different sites. I would like to set the menu label to the current site name. I have tried using page.props.path and page.props.primaryview but both of them come with extra fluff that I can’t figure out how to trim off.  
Primaryview comes with the whole path so “foldername/anotherfoldername/the part I actually want”  
I have tried splitting that with split({value},"/")[0,2] but it says 2 is too long for length 0. I figured the error would go away once it has an actual path to work with, but when implemented it is blank with an error overlay.

I would appreciate any tips.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 4, 2022, 7:25pm UTC](https://forum.inductiveautomation.com/t/help-manipulating-strings-in-expressions-or-scripts/55777/2 "2022-02-04T19:25:31Z")

</div>

Script:

```auto
# -1 always gives the final item of the array
"foldername/anotherfoldername/the part I actually want".split("/")[-1]

```

Expression:

```auto
split("foldername/anotherfoldername/the part I actually want", "/")[len(split("foldername/anotherfoldername/the part I actually want", "/")) - 1,0]

```
