I am trying to write a regex to which will strip the all HTML entities apart from the allowded ones but not successfull.
Hi,In the text area user can enter allowded HTML entities. If user enters HTML entity other than the allowded HTML entities, then it should be stripped out.
Hi All,Sorry for late reply.My requirment is to strip all the HTML entities except following : © ® ¹ ™ and &from the text area.I have written the following reges for that : var entitiesPattern = "&(?!(copy|reg|sup1|trade|amp)\\b)[^&\s\;]*(\"; var entitiesRegularExp = new RegExp(entitiesPattern,"g"); var textAfterEntitiesRemoved = text.replace(entitiesRegularExp,''); where text contains the content entered in the text area. But this regex is not working in all the condition. Although its stripping all the unwanted entities. But its failing in one condition : For example if enter :"Hello how are you & where are you now days;"then it strips : "& where are you now days;" from the enterd content and leaves : "Hello how are you".Could any one please tell me where i am wrong?Thanks in advance.A.S.
I tried the following reges and its working."&(?!(copy|reg|sup1|trade|amp)\\b)[^&\\s\;]*(\";
It is *slightly* different. \\b and \\s
I'm not sur but *think* that's just misguided attempts to *escape an escape* for the vBulletin Forum (eg, Forum's artifact). In any case, \s and \b within regex make sense, \\s and \\b taken verbatim make none whatever (match reverse slash followed by the letter s or b...)
Yea that was my thought as well. The regex with the \\b would certainly not behave in the way he expects it.