Skip to main content
Feedback

Split a value into multiple parts

This sample JavaScript or Groovy custom scripting function splits a single address street "block" into individual lines (up to five) based on a line break. This can also be accomplished with the standard String Split function.

Inputs- street (Character)
Outputs- line1
- line2
- line3
- line4
- line5

Script

lines = street.split("\n");

line1 = lines[0];

if (lines.length > 1) {
line2 = lines[1];
}

if (lines.length > 2) {
line3 = lines[2];
}

if (lines.length > 3) {
line4 = lines[3];
}

if (lines.length > 4) {
line5 = lines[4];
}