javascript - Regexp with accented characters on match -


i have check forbidden words in text area when user tries validate. forbidden words list stored in jsblacklist array, , part of code far :

var fieldvalue = value; var hasforbiddenword = false; (i = 0; < jsblacklist.length; i++) {     var regex = new regexp("\\b"+jsblacklist[i]+"\\b","gi");     fieldvalue = fieldvalue.replace(regex, '***');     hasforbiddenword = hasforbiddenword || fieldvalue.match(regex); } value = fieldvalue; 

but problem is, jsblacklist has accented characters, while user write without accent (for example, jsblacklist can have "déjà", , user has typed "deja", "déja" or "dejà").

how can check missing accents ?

nb "marked duplicate" : duplicate questions "regexp without accent check text accents", mine "regexp accent check text potential missing accents".

one way accomplish change black list bit:

replace characters accent same alternation.

for example: "déjà" to: "d(é|e)j(à|a)"

if blacklist big, want automate replacements, @ end convenient have black list written this.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -