# Split String message

**URL:** https://discourse.nodered.org/t/split-string-message/14801
**Category:** General
**Created:** [26 August 2019 19:52 UTC](https://discourse.nodered.org/t/split-string-message/14801 "2019-08-26T19:52:44Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 19:52 UTC](https://discourse.nodered.org/t/split-string-message/14801/1 "2019-08-26T19:52:45Z")

</div>

Hi. Can someone please help me how to split this string message.

something like this

213444  
ri1  
CQ

Best regards Niclas

![03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0c4070169dafa8d2ce05a4cc4cafa0f087e82561.png)

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:04 UTC](https://discourse.nodered.org/t/split-string-message/14801/2 "2019-08-26T20:04:15Z")

</div>

Do you need all of the parts?

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:06 UTC](https://discourse.nodered.org/t/split-string-message/14801/3 "2019-08-26T20:06:15Z")

</div>

Sorry, I see you do!

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:06 UTC](https://discourse.nodered.org/t/split-string-message/14801/4 "2019-08-26T20:06:37Z")

</div>

No actually I just need /CQ but it can also end with /BA02 so need everything after the last /

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:08 UTC](https://discourse.nodered.org/t/split-string-message/14801/5 "2019-08-26T20:08:28Z")

</div>

I don't need the / just CQ

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:08 UTC](https://discourse.nodered.org/t/split-string-message/14801/6 "2019-08-26T20:08:36Z")

</div>

Is the start of the string always the same length up till the last "/"?

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:09 UTC](https://discourse.nodered.org/t/split-string-message/14801/7 "2019-08-26T20:09:53Z")

</div>

Not sure. But i think so.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [26 August 2019 20:12 UTC](https://discourse.nodered.org/t/split-string-message/14801/8 "2019-08-26T20:12:03Z")

</div>

Have you searched for how to split strings in JavaScript? There are lots of guides online and it may be worth spending a little time learning some of the basics of JavaScript string handling.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:12 UTC](https://discourse.nodered.org/t/split-string-message/14801/9 "2019-08-26T20:12:07Z")

</div>

You could try the switch node and search for /CQ or /BA02.

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:15 UTC](https://discourse.nodered.org/t/split-string-message/14801/10 "2019-08-26T20:15:47Z")

</div>

I can't just search for /CQ or /BA02. I can be hundreds of different combinations.

Can I use some function that just shows the message after the 14 character?

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:18 UTC](https://discourse.nodered.org/t/split-string-message/14801/11 "2019-08-26T20:18:41Z")

</div>

You just posted exactly what you require, this should have been your first post!!

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [26 August 2019 20:19 UTC](https://discourse.nodered.org/t/split-string-message/14801/12 "2019-08-26T20:19:46Z")

</div>

Can you specify what the structure of the string is then? Is it always the same length? Does it always have some characters consistently in the same place?

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:23 UTC](https://discourse.nodered.org/t/split-string-message/14801/13 "2019-08-26T20:23:24Z")

</div>

I don´t really know if this will work. But it will be worth a try. Most of all i want the whole message I three different parts. But if know how to accomplish the 14 character I will try with this before I figure out how to do it.

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:25 UTC](https://discourse.nodered.org/t/split-string-message/14801/14 "2019-08-26T20:25:14Z")

</div>

This is the code an alarmsystem send to the alarm central. 213444 is the costumer number. ri1 is area 1 and CQ is a sia that stands for disarmed. BA02 stands for BurglerAlarm on section 2

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:26 UTC](https://discourse.nodered.org/t/split-string-message/14801/15 "2019-08-26T20:26:50Z")

</div>

So I think the length is the same as long that you don't use mere than 9 areas

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [26 August 2019 20:28 UTC](https://discourse.nodered.org/t/split-string-message/14801/16 "2019-08-26T20:28:29Z")

</div>

> [@knolleary](#):
>
> Have you searched for how to split strings in JavaScript?

I think you should follow this advice.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [26 August 2019 20:29 UTC](https://discourse.nodered.org/t/split-string-message/14801/17 "2019-08-26T20:29:01Z")

</div>

Go read about String.substring() and String.split() on the mdn website.

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 20:29 UTC](https://discourse.nodered.org/t/split-string-message/14801/18 "2019-08-26T20:29:32Z")

</div>

I will do that!! Thanks for the advice! 👍

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [26 August 2019 20:32 UTC](https://discourse.nodered.org/t/split-string-message/14801/19 "2019-08-26T20:32:26Z")

</div>

Have a look at slice() - [https://www.w3schools.com/jsref/jsref\_slice\_string.asp](https://www.w3schools.com/jsref/jsref_slice_string.asp)  
I used it in this example -[Reading String of Hex from T-zone RD05 problem](https://discourse.nodered.org/t/reading-string-of-hex-from-t-zone-rd05-problem/14679/6)

---

<div class="post-metadata">

### Author: ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)
#### Post date: [26 August 2019 21:02 UTC](https://discourse.nodered.org/t/split-string-message/14801/20 "2019-08-26T21:02:37Z")

</div>

Can you tell me if I am close? I think I have to change parseInt(test); to something like parseString(test) but I don't know how to declare it.

 ![13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/917a477fae8d969431d084d8e983bf118411fd75.png)

[Next page](https://discourse.nodered.org/t/split-string-message/14801.md?page=2)
