I'm checking if my string has special characters to replace but for the following string I'm having the following problem
String
(Lot P Verdes) Function
function retira_acentos(palavra) { com_acento = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ'; sem_acento = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC'; nova=''; for(i=0;i<palavra.length;i++) { if (com_acento.search(palavra.substr(i,1))>=0) { nova+=sem_acento.substr(com_acento.search(palavra.substr(i,1)),1); } else { nova+=palavra.substr(i,1); } } return nova.toUpperCase(); } Error
line: if (com_acento.search(palavra.substr(i,1))>=0)
Uncaught SyntaxError: Invalid regular expression: /(/: Unterminated group
searchuses regular expressions, and if you feed it strings, it tries to automatically convert them into one. But(on its own is not a valid regular expression to begin with, because(has a special meaning in regex.