Highlighted
Micro Focus Expert
Micro Focus Expert
195 views

(SM) Support Tip: How to extract elements from a delimited list using JavaScript

The following javascript code helps to separate each of the elements from a list separated by semicolon.
For example, the eventout records may contain a list of the emails to which a notification will be sent

thelist="firstemail@domain.com;secondemail@domain.com;thirdemail@domain.com;fourthemail@domain.com;";
var count=1;
var posdelimiter=0;
var oneemail="";
while (thelist.length!=0)
{
        posdelimiter=thelist.indexOf(";");//This delimiter can be changed to any character that separate the list, in this case a semicolon
        oneemail=thelist.substring(0,posdelimiter);
        // Section to add any code where each of the values from the list will be used. In this case, olny print each value
        print("element number "+count+" from the list is: "+oneemail);
        //
        thelist=thelist.substring(posdelimiter+1,thelist.length);
        count++;
}

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.