# String Leading Char(s) Removal

**URL:** <https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [November 21, 2025, 10:27pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371 "2025-11-21T22:27:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [November 21, 2025, 10:27pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/1 "2025-11-21T22:27:13Z")

</div>

I have a string custom parameter like XXXXX-YYY where the XXXXX is always 5-digits, leading digits are 0 if not used and YYY are characters. I would like to strip off any leading 0s.

For instance: 22106-ABC → 22106-ABC, 01574-ABC →1574-ABC, 00248-ABC → 248-ABC etc

What’s a “nice” way to do this?

---

<div class="post-metadata">

**Author:** ![tgarrison](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tgarrison/32/80965_2.png) [@tgarrison](https://forum.inductiveautomation.com/u/tgarrison)\
**Post date:** [November 21, 2025, 10:32pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/2 "2025-11-21T22:32:51Z")

</div>

regex: ^0\*(\S\*)  
that will return everything other than leading 0's

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [November 21, 2025, 10:33pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/3 "2025-11-21T22:33:12Z")

</div>

How do I use that in the expression language?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [November 21, 2025, 10:47pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/4 "2025-11-21T22:47:33Z")

</div>

Would using `right()` do the job?

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [November 21, 2025, 10:48pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/5 "2025-11-21T22:48:52Z")

</div>

Combination of `right()` `len()` and `search()` might do it. There could be extra chars to the right, but the first is always 5 digits

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [November 21, 2025, 10:52pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/6 "2025-11-21T22:52:36Z")

</div>

The easiest way that comes to mind when I think of it that way may be to just do `int(left())` for the first 5, let Ignition do the stripping, and then concat with the remaining string using `right()` and `len()`-5

```python
toStr(toInt(left({tag}, 5))) + right({tag}, len({tag}) - 5)

```

Of course, there are more ways to skin the cat, but I like simple and readable solutions, which typically does not include regex.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [November 21, 2025, 10:56pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/7 "2025-11-21T22:56:41Z")

</div>

try `split(sourceString, "^[0|\\D]*")`?

Edit: this fails if a letter is the first thing after your leading zeros.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 21, 2025, 10:57pm UTC](https://forum.inductiveautomation.com/t/string-leading-char-s-removal/112371/8 "2025-11-21T22:57:27Z")

</div>

You can use `substring()` instead of `right()` to avoid needing `len()`.

You cannot add an integer to a string, though. I recommend:

```python
stringFormat("%d%s", toInt(left({tag})), substring({tag}, 5))

```
