Parsing a comma-delimited string into variables in a pattern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 11:42 AM
Possibly brain-fog, but I can't figure out how to parse a comma-delimited string variable value into multiple variables in a Service Mapping Pattern I'm writing. Here's what I mean:
I have a variable that contains a,b,c,d,e,f,g but I don't know how many letters there will be - maybe zero, maybe one, maybe many.
I want to end up with a table with a column called letters and a row for each letter.
Any ideas?
Note: actual values converted to letters to protect the data 😉
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 11:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 12:50 PM
Hi Ashutosh, I don't think that will work for my needs as the SNMP query reads from finite locations. What I need is something along the lines of...
- Create a table
- Parse the comma-delimited variable value
- Write the parsed values into rows in the table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 01:01 PM
I would create an array of the comma-delimited variable values, something like
var myArr = variablename.split(',');
You can then reference each element via
myArr[0]; //where 0 is the index number of the element
or loop through the array like so
for(var i=0; i<myArr.length; i++){
//do something with myArr[i];
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2020 01:09 PM
Hi Brad, That's exactly what I had in mind, but I also need to create a table and push the values into it as rows. In reality, each letter is a server that I want to make a connection to. I figure if I can put them into a table, I can create connections row by row...
host $theTable[*].server
port $theTable[*].port
I can't figure out how in a Pattern to create a table and pass the array values from inside the for loop in the script.