Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
Created January 20, 2014 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsteinshouer/8530344 to your computer and use it in GitHub Desktop.
Save jsteinshouer/8530344 to your computer and use it in GitHub Desktop.
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