I'm trying to return a comma separated string without the items that end in 'non'.
Source:
id = '2345,45678,3333non,489,2333non';
Expected Result:
id = '2345,45678,489';
I'm using code that I found here: remove value from comma separated values string
var removeValue = function(list, value, separator) {
separator = separator || ",";
var values = list.split(separator);
for (var i = 0; i < values.length; i++) {
if (values[i] == value) {
values.splice(i, 1);
return values.join(separator);
}
}
return list;
}
Is there a way to make the line (values[i] == value)
use a wildcard?