
February 28th, 2004, 09:29 AM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
regular expressions
I want to be able to strip out any dirty microsoft html from a form submission and leave only certain tags that I specify. I'm starting by allowing only p and h1 tags. I can't get the regular expression correct however because it always leaves <?xml..., <o:... and <span... tags even though it deletes the other tags I want gone.
Here is the code I'm using...
I think this should strip out all tags except p and h1:
Code:
<cfset form.content = rereplacenocase(form.content, "</?[^(p)(h1)]*>", "", "all")>
I use the next two lines to take out any attributes within the remaining p and h1 tags and replace them with clean, no attribute versions:
Code:
<cfset form.content = rereplacenocase(form.content, "<p[^>]*", "<p", "all")>
<cfset form.content = rereplacenocase(form.content, "<h1[^>]*", "<h1", "all")>
Can anyone tell me what I'm doing wrong? You can view this project at URL. Thank you so much for any help you can provide.
|