This function uses the callback to filter the elements in a string.
stringFilter(string,callback)
returns string
string.filter(callback)
Name | Type | Required | Default | Description |
---|---|---|---|---|
string | string | Yes | Original input string to search. | |
callback | any | Yes | The closure function that is executed for each element in the string. |
Return only the letters in the string that meet the callback condition.
letters="zzQQZ";
callback=function(inp){return inp=="z";}
onlyZs = StringFilter(letters,callback);
writeOutput(onlyZs);
Return only the letters in the string that meet the callback condition.
letters="zzQQZ";
callback=function(inp){return inp=="z";}
onlyZs = letters.filter(callback);
writeOutput(onlyZs);