# Split() expression problem

**URL:** <https://forum.inductiveautomation.com/t/split-expression-problem/74110>\
**Category:** General Discussion\
**Created:** [May 24, 2023, 9:03am UTC](https://forum.inductiveautomation.com/t/split-expression-problem/74110 "2023-05-24T09:03:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aske\_lykke](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@aske\_lykke](https://forum.inductiveautomation.com/u/aske_lykke)\
**Post date:** [May 24, 2023, 9:03am UTC](https://forum.inductiveautomation.com/t/split-expression-problem/74110/1 "2023-05-24T09:03:00Z")

</div>

Hello,

The split() expression function does not work according to the documentation. I am trying to split the following string: "2.108.016.14.HM.003|FO PUMPE RETUR 14|X|INDE|FO2 STOR|Tæller 10" at each "|", but i get a dataset with a row for each character. Dataset [61R,1C].  
I am using the following code:  
split(tag({Root Container.Pumper.Text\_2.TagPath}+'/'+{Root Container.Pumper.Text\_2.Tag}+'.Documentation'),"|")

Best regards,  
Aske Rømer Lykke

---

<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:** [May 24, 2023, 11:50am UTC](https://forum.inductiveautomation.com/t/split-expression-problem/74110/2 "2023-05-24T11:50:37Z")

</div>

`split()` uses a regular expression, and the pipe character is a special in regexes. You will need to escape it.

---

<div class="post-metadata">

**Author:** ![Tim\_Carlton](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim_carlton/32/52835_2.png) [@Tim\_Carlton](https://forum.inductiveautomation.com/u/Tim_Carlton)\
**Post date:** [May 24, 2023, 11:59am UTC](https://forum.inductiveautomation.com/t/split-expression-problem/74110/3 "2023-05-24T11:59:52Z")

</div>

A regEx that would work is `"[|]"`

```auto
{
  "valueSource": "memory",
  "dataType": "String",
  "name": "TestString",
  "value": "2.108.016.14.HM.003|FO PUMPE RETUR 14|X|INDE|FO2 STOR|Tæller 10",
  "tagType": "AtomicTag"
}

```

```auto
{
  "valueSource": "derived",
  "deriveExpressionGetter": "split({source},\"[|]\")",
  "dataType": "DataSet",
  "sourceTagPath": "[~]TestString",
  "name": "New Tag",
  "tagType": "AtomicTag"
}

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6974811679e52bace3574cb4dfc1762a2ef9ebb.png)

---

<div class="post-metadata">

**Author:** ![aske\_lykke](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@aske\_lykke](https://forum.inductiveautomation.com/u/aske_lykke)\
**Post date:** [May 24, 2023, 12:06pm UTC](https://forum.inductiveautomation.com/t/split-expression-problem/74110/4 "2023-05-24T12:06:04Z")

</div>

> [@Tim\_Carlton](#):
>
> `split({source},\"[|]\")`

Thx, that worked 🙂
