StringContains Deprecated

Deprecated. No available replacement. Checks whether substring is within string. Returns - yes - string contains substring. no - string does not contain substring. If stringSeperator is provided, the substring will be split using the separator, and each item will be checked. If one of the items will be found in the string, the srcipt will return yes. This script is deprecated. The StringContainsArray filter implements the exact functionality.

javascript · Developer Tools

Source

var str = args.string;
var substring = args.substring;
var substringSeperator = args.substringSeperator;

if (Array.isArray(substring) || substringSeperator) {
    var arr = Array.isArray(substring) ? substring : substring.split(substringSeperator);
    for (var i = 0; i < arr.length; ++i) {
        if (arr[i] && str.indexOf(arr[i]) > -1) {
                return 'yes';
        }
    }
} else {
    if (str.indexOf(substring) > -1) {
        return 'yes';
    }
}
return 'no';