# Extract value from message

**URL:** <https://discourse.nodered.org/t/extract-value-from-message/21305>\
**Category:** General\
**Created:** [5 February 2020 12:32 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305 "2020-02-05T12:32:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abigor](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Abigor](https://discourse.nodered.org/u/Abigor)\
**Post date:** [5 February 2020 12:32 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305/1 "2020-02-05T12:32:45Z")

</div>

Hi,

I'm trying to figure out how to extract the value from following message:

"a100=16974\x03"

The value I want is the digits after the "=", but excluding the "\x03". The value can be 0 - 65535 (2byte)

I've tried to use $substring(payload,5,9) but of course this isn't suitable since there can be 1 up to 5 digits after the "=" sign.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 February 2020 13:00 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305/2 "2020-02-05T13:00:16Z")

</div>

If the `\x` will always be there you could do a split on the `=` then a split on the `\x`

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [5 February 2020 13:17 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305/3 "2020-02-05T13:17:46Z")

</div>

Or determine the position of = and / by using the build in indexOf() function

> **[String.prototype.indexOf()](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)**
>
> Die indexOf() Methode gibt den Index der Zeichenkette innerhalb des aufrufenden String Objekts des ersten Vorkommnis des angegebenen Wertes beginnend bei fromIndex zurück. Gibt -1 zurück, wenn der Wert nicht gefunden wurde.

Perhaps you have to add or subtract a 1.

---

<div class="post-metadata">

**Author:** ![Abigor](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Abigor](https://discourse.nodered.org/u/Abigor)\
**Post date:** [5 February 2020 13:40 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305/4 "2020-02-05T13:40:30Z")

</div>

Thank you, that worked great 😄

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 April 2020 13:40 UTC](https://discourse.nodered.org/t/extract-value-from-message/21305/5 "2020-04-05T13:40:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
