Split() expression problem

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

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

1 Like

A regEx that would work is "[|]"

{
  "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"
}
{
  "valueSource": "derived",
  "deriveExpressionGetter": "split({source},\"[|]\")",
  "dataType": "DataSet",
  "sourceTagPath": "[~]TestString",
  "name": "New Tag",
  "tagType": "AtomicTag"
}

image

4 Likes

Thx, that worked :slight_smile: