I'm trying to replace letters in a string based on an array of letters.
What I'm doing so far is
var value = '00-.Tday(52)'
if(!textService.containsLettersExcept(value, ['t', '.', '-'])){
// yay
}
function containsLettersExcept(text, exceptions){
console.info('text before : ', text)
for(var i = 0; i< exceptions.length; i++){
var char = exceptions[i];
text = text.replace(/char/gi, '');
}
console.info('text : ', text)
return text.match(/[a-z]/i);
}
This however tries to remove the string "char" rather than the variable char
from the string text