Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ivanionut/e2facaeefa3b603a76e7 to your computer and use it in GitHub Desktop.
Save ivanionut/e2facaeefa3b603a76e7 to your computer and use it in GitHub Desktop.
<cffunction name="sanitizeEmailList" access="public" returnType="String" output="false">
<cfargument name="emailList" type="String" required="true" />
<cfset var local = {} />
<cfset local.email = '' />
<cfset local.RegEx = "[a-z0-9!##$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!##$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"/>
<cfloop list="#arguments.emailList#" index="local.i">
<cfset local.address = ReMatch(local.RegEx,local.i)/>
<cfif ArrayLen(local.address)>
<cfset local.email = ListAppend(local.email,local.address[1]) />
</cfif>
</cfloop>
<cfreturn local.email />
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment