StringContainsArray

Checks whether a substring or an array of substrings is within a string array(each item will be checked). Supports single strings as well. For example, for substrings ['a','b','c'] in a string 'a' the script will return true.

javascript · Filters And Transformers

Source

var str = args.left;
var substring = args.right;

if(!str || !substring){
    return false;
}

if (Array.isArray(substring)) {
    var arr = substring;
    for (var i = 0; i < arr.length; ++i) {
        if (arr[i] && str.indexOf(arr[i]) > -1) {
                return true;
        }
    }
} else {
    if (str.indexOf(substring) > -1) {
        return true;
    }
}

return false;

README

Checks whether a substring or an array of substrings is within a string array (each item will be checked). Single strings are also supported. For example, for substrings [‘a’,’b’,’c’] in a string ‘a’ the script will return true.

Script Data


Name Description
Script Type javascript
Tags filter, string

Inputs


Argument Name Description
left The string to search in. For example, “string1”.
right The array of substrings to search in the string. For example, [“string1”,”string2”].

Outputs


There are no outputs for this script.