I am getting an error on the rereplacenocase ```<c...
# lucee
g
I am getting an error on the rereplacenocase
Copy code
<cffunction name="removeDivsWithClass" access="public" returntype="string" output="false">
    <cfargument name="inputString" type="string" required="yes">
    
    <cfset var cleanedString = arguments.inputString>
    

    <cfset cleanedString = reReplaceNoCase(cleanedString, "<div[^>]*class\\s*=\\s*[\"']preclass[\"'][^>]*>", "", "ALL")>
    <cfset cleanedString = reReplaceNoCase(cleanedString, "</div>", "", "ALL")>
    

    <!--- Note: This is a simplistic approach and might not cover all cases perfectly --->
    <cfset cleanedString = reReplaceNoCase(cleanedString, "<div>", "", "ALL")>
    <cfset cleanedString = reReplaceNoCase(cleanedString, "</div>", "", "ALL")>
    
    <!--- Return the cleaned string --->
    <cfreturn cleanedString>
	</cffunction>
don't see any issues in this code error <cfset cleanedString = reReplaceNoCase(cleanedString, "div[^]*class\\s*=\\s*[\"']preclass[\"'][^>]*>", "", "ALL")> *MESSAGE*Invalid Syntax Closing [)] for function [rereplacenocase] not found*STACKTRACE*The Error Occurred in tags.cfc: line 769 > 767: > 768: > *769: <cfset cleanedString = reReplaceNoCase(cleanedString, "div[^]*class\\s*=\\s*[\"']preclass[\"'][^>]*>", "", "ALL")>*
m
double up your double quotes in the regular expression to escape them. I would very much caution against trying to 'clean' html this way though. I would use owasp antisamy, owasp java html sanitizer, or jsoup for the task.
👍 4
a
It's probably timely for ppl to reacquaint themselves with https://stackoverflow.com/a/1732454/894061.
👍 1