Splitting strings
split()
can be used to break up a string at a specified delimiter
String(node.<property>).split([delimiter])
splits up a value at defined intervals – similar to performing a delimited text to columns function in Excel
A space or a comma are common delimiters
In this example it is possible to split full name into first name and last name
String(node.fullname).split(" ")
It the example shown two results are returned as the string has been split in two
Putting [0]
or [1]
will return the substring before or after the delimiter
- A.
String(node.fullname).split(" ")[0]
returns Anna - B.
String(node.fullname).split(" ")[1]
returns Harris
Other characters may be used to split strings:
Using the @
symbol as the delimiter and including the [1]
substring it is possible to extract the domain from email addresses
String(node.email).split("@")[1]