Skip to content

Instantly share code, notes, and snippets.

Created September 15, 2016 17:22
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 anonymous/0c09ff9ee3d08314edd0d5ccb5c36894 to your computer and use it in GitHub Desktop.
Save anonymous/0c09ff9ee3d08314edd0d5ccb5c36894 to your computer and use it in GitHub Desktop.
TryCF Gist
<!--- JS with comment --->
<cfsavecontent variable="variables.jsWithCommment">
<script type="text/javascript">
// comment
var a=1; // another comment
/* try{if (...)}; */
var b=2;
</script>
src="//domain.com"
</cfsavecontent>
<!--- JS with comment --->
<b>JS with comment:</b><br>
<cfdump var="#variables.jsWithCommment#"><br><br>
<!--- Replace with first capture for each branch --->
<cfset variables.regex = '(?:("\/\/[^"]*?")|\/\*.*?\*\/|\/\/.*?\n)'>
<cfset variables.jsWithoutComment = reReplace(variables.jsWithCommment, variables.regex, "\1", "ALL")>
<!--- JS without comment --->
<b>JS without comment(s):</b><br>
<cfdump var="#variables.jsWithoutComment#">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment