I have to check for forbidden words in a text area when a user tries to validate.
The forbidden words list is stored in the jsBlackList
array, and this is part of my code so far :
var fieldValue = value;
var hasForbiddenWord = false;
for (i = 0; i < jsBlackList.length; i++) {
var regex = new RegExp("\\b"+jsBlackList[i]+"\\b","gi");
fieldValue = fieldValue.replace(regex, '***');
hasForbiddenWord = hasForbiddenWord || fieldValue.match(regex);
}
value = fieldValue;
But the problem is, jsBlackList
has some accented characters, while the user could write without accent (for example, jsBlackList can have "déjà", and the user has typed "deja", "déja" or "dejà").
How can I check for missing accents ?
NB about "Marked as duplicate" : the duplicate questions are about "regexp without accent to check text with accents", mine was "regexp with accent to check text with potential missing accents".