Can anyone provide a quick solution to help me with this issue?
I am trying to remove all html tags from a string, except for the ones specified in a whitelist (variable).
This is my current code:
whitelist = 'p|br|ul|li|strike|em|strong|a',
reqExp = new RegExp('<\/?[^>|' + whitelist + ']+\/?>');
The problem I am facing is that it does not remove certain tags like b
because it matches the b
from the br
tag within the whitelist.
I have tried various methods but haven't found the right solution yet.
How can I instruct the regex to do something like /.WITHOUT(smth)/
(meaning: match all except for specific elements)?