I have got a table where one of the column has text mixed with HTML data. This was due to a bug (fixed) in a script, but the SQL data needs to be edited to reflect the changes. The column has a type nvarchar(max, null)
. All I need to do is find tags such as <a img="lkss">
,<div attr=val>
and replace them with empty string ""
. I looked into this, but the solution says how to replace the entire contents based on one pattern. My problem is that I need to replace contents partly, but preserve clean text (i.e. not HTML tags/attributes). Any suggestion/help is appreciated.
Test column data:
<div attr=val; color=somecolor>inside text<div some=val><a some=val>Inside anchor
Expected result:
inside textInside anchor