This works great removing ALL html from a string/DB text type field, how can I omit break tags:
update hazHRA set identityRisk=dbo.RegexReplace('<(?:[^>''"]*|([''"]).*?\1)*>',
'',identityRisk,1,1);
I wish to keep the
<br>
only
This should do the job:
(?i)<(?:(?!br>|br/>)[^>'"]*|(['"]).*?\1)*>
(?i): Case insensitive.
(?!br>|br/>): Negative lookahead.
Online demo.
If you could use quantifiers in lookaheads you may use this:
(?i)<(?:(?!br\s*>|br\s*/>)[^>'"]*|(['"]).*?\1)*>
This will ensure to not match <br > with spaces.
Online demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With