Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Coldfusion rereplace example to remove iframes
<cfsetting showdebugoutput="false">
<!--- Here is some html content with iframes --->
<cfset sOriginalContent = "
<h3>Title Here</h3>
<pHere is a paragraph</p>
<iframe width=""560"" height=""315"" src=""//www.youtube.com/embed/B7UmUX68KtE"" frameborder=""0"" allowfullscreen></iframe>
<p>another paragraph</p>
<iframe width=""560"" height=""315"" src=""//www.youtube.com/embed/VnT7pT6zCcA"" frameborder=""0"" allowfullscreen /></iframe>
<p style=""font-weight: bold"">paragraph 3</p>
">
<!--- Use regex to remove iframe tags from content --->
<cfset sNewContent = rereplaceNoCase(sOriginalContent,"<iframe.*?</iframe>","","all")>
<!--- Display the original content --->
<h1>Original Content</h1>
<cfoutput>#sOriginalContent#</cfoutput>
<!--- Display the modified content --->
<h1>Without Iframes</h1>
<cfoutput>#sNewContent#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment