Look and exclude an element in an array?


I’ve a custom attribute having an array of app names defined in an host definition. All elements are necessary and pre-defined. I would like to search an element in the array starting with for e.g. tar: and exclude it and return only other elements in a function. The other elements don’t have any specific patterns.

Is this something possible in some way?

Please advise,

Hi @monigacom

You could write a function that excludes all elements which match a pattern. Maybe something like this:

var result = []
for (var element in array) {
  if(!match(pattern, element){

Kind regards

Hi @ritzgu

Thank you so much. It worked as suggested!

1 Like