Hi All,
I want to escape characters in javascript,
['a', 'à','á','â','ä','æ','ã','å','ā'], ['c', 'ç', 'ć', 'č'], ['e', 'è','é','ê','ë','ē','ė','ę'], ['i', 'ï','ï','í','ī','į','î'], ['l', 'ł'], ['n', 'ñ', 'ń'], ['o', 'ô', 'ö', 'ò', 'ó', 'œ', 'ø', 'ō', 'õ' ], ['s', 'ß', 'ś', 'š' ], ['u', 'û', 'ü', 'ù', 'ú', 'ū'], ['y', 'ÿ'], ['z', 'ž', 'ź', 'ż'] ];
function escapeSpecialChars(str) {
return str
.replace(/&/g, "&")
.replace(/"/g, '\\"')
.replace(/
.replace(/>/g, ">")
.replace(/'/g, "'")
.replace(/`/g, "`")
}
for(var i =0; i<cols.length;i++){
var str=escapeSpecialChars(cols[i]);
var myElements = MyTable.querySelectorAll('[data-header=\''+str+'\']');
I
I have written the function above but want to esacpe all the columns which contains special chars .
Can anyone suggest how to include below chars as well
to club in function.;
Hi.
You can use regular expression to remove all special characters, you can have a look at this example.
/[^\w\d]/g
Example Regex
Regards