I'm facing a challenge with my telerik RadEditor where users can input HTML that gets saved to my database. While this usually works well, I encounter issues when the CSS attributes position: absolute; or z-index: 100; (any # for z-index) are present in the element's style attribute.
After exploring telerik options without success, I am seeking a Regex solution to remove these CSS properties in the code behind. The project is in VB.Net (I typically work in C#), adding to the complexity. Although I found an example on Stack Overflow, my requirements differ and crafting my own Regex poses a challenge...
The snippet I attempted so far seems ineffective:
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'm unsure if it's a syntax error or if my approach is flawed...
Note that I need to eliminate these properties regardless of semicolon presence and allow for spaces between the colon. The following variations should be removed:
- position: absolute;
- position : absolute;
- position: absolute
- position : absolute
- z-index: anyInt;
- z-index : anyInt;
- z-index: anyInt
- z-index : anyInt
The key requirement is to remove all instances, not just the first one. Any guidance on resolving this issue would be highly valued!