I have a telerik RadEditor that a user is able to enter HTML into an editor and save to my database. Most of the time this works great, but I'm having a problem with certain instances when there is a css attribute of position: absolute; or z-index: 100; (could be any # for z-index) within the element's style attribute.
I looked at the telerik options and don't see an out of the box solution (correct me if I'm wrong) but I am basically trying to find a Regex that I can use to strip out those CSS properties in the code behind. This project uses VB.Net (I am a C# developer) so I'm already fighting an uphill battle. I originally was looking at this example from stack but I'm not exactly trying to do the same thing and I am no master of writing my own Regexes...
Here's what I have so far that does not work as expected:
Dim html As String = "<div style=""position: absolute; z-index: 6;"">a bunch of other html</div>"
html = Regex.Replace(html, "((?:position|z-index)(?:[^:]+):(?:\\s*))([^;]+)", "")
I don't know if I just have a small syntax issue, or if I'm completely off in my approach...
Please note, I need to remove the properties with or without a semicolon and ideally should ignore a space between the colon, so these should all get removed:
- position: absolute;
- position : absolute;
- position: absolute
- position : absolute
- z-index: anyInt;
- z-index : anyInt;
- z-index: anyInt
- z-index : anyInt
The only other requirement is that I to strip out ALL occurrences, not just the first. Any help with solving this issue will be greatly appreciated!