# Handlebar help with substring

**URL:** <https://connective.celigo.com/t/handlebar-help-with-substring/3831>\
**Category:** Integrator.io\
**Created:** [March 16, 2025, 7:25pm UTC](https://connective.celigo.com/t/handlebar-help-with-substring/3831 "2025-03-16T19:25:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_Wilcox](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@Brad\_Wilcox](https://connective.celigo.com/u/Brad_Wilcox)\
**Post date:** [March 16, 2025, 7:25pm UTC](https://connective.celigo.com/t/handlebar-help-with-substring/3831/1 "2025-03-16T19:25:13Z")

</div>

Is it possible to strip the first and last character off of a string using a Handlebar expression? I have a product code of "BQ24-00000123542N" that I want to be "Q24-000001233542".

Or does this require javascript?

---

<div class="post-metadata">

**Author:** ![Marin\_Spasov](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Marin\_Spasov](https://connective.celigo.com/u/Marin_Spasov)\
**Post date:** [March 16, 2025, 9:21pm UTC](https://connective.celigo.com/t/handlebar-help-with-substring/3831/2 "2025-03-16T21:21:15Z")

</div>

hi, it is possible using regex. Assuming simple structure such as {"productCode": "abba"},

the following should do the job: {{regexReplace productCode "" "^.|.$" "gm"}} and output is "bb".

More info here: [https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-helper-reference](https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-helper-reference)

I'm by no means a regex expert but this is a useful resource for testing: [https://regex101.com/](https://regex101.com/)

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [March 17, 2025, 3:05pm UTC](https://connective.celigo.com/t/handlebar-help-with-substring/3831/3 "2025-03-17T15:05:20Z")

</div>

You could also do this

```handlebars
{{substring (substring code 1) 0 (subtract code.length 2)}}

```

 ![This image displays a Handlebars template code snippet that processes a substring operation on a code, and shows both the available resource data and the resulting output. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/c/cb99c1e9c28867b36ecd93d8c0f87cadc60982b4.png)
