getEmails(str)
Last updated June 13, 2011
Version: 3 | Requires: ColdFusion 5 | Library: StrLib
Description:
This UDF will search a string for email addresses and return the matches as a list.
Return Values:
Returns a list.
Example:
<cfoutput>#getEmails(emailList)#</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| str | String to search. | Yes |
Full UDF Source:
<cfscript>
/**
* Searches a string for email addresses.
* Based on the idea by Gerardo Rojas and the isEmail UDF by Jeff Guillaume.
* New TLDs
* v3 fix by Jorge Asch
*
* @param str String to search. (Required)
* @return Returns a list.
* @author Raymond Camden (ray@camdenfamily.com)
* @version 3, June 13, 2011
*/
function getEmails(str) {
var email = "(['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.((aero|coop|info|museum|name|jobs|travel)|([a-z]{2,3})))";
var res = "";
var marker = 1;
var matches = "";
matches = reFindNoCase(email,str,marker,marker);
while(matches.len[1] gt 0) {
res = listAppend(res,mid(str,matches.pos[1],matches.len[1]));
marker = matches.pos[1] + matches.len[1];
matches = reFindNoCase(email,str,marker,marker);
}
return res;
}
</cfscript>
Search CFLib.org
Latest Additions
Adam Cameron added
composeDateTime
19 day(s) ago
Chris Weller added
convertQueryStri...
a while ago
Greg Nettles added
arrayDiff
a while ago
Nathan Dintenfass added
ArrayOfStructsSo...
a while ago
Top Rated
backupDatabase
Rated 5.0, 36 time(s)
indentXml
Rated 5.0, 10 time(s)
deAccent
Rated 5.0, 6 time(s)
countArbitraryDa...
Rated 5.0, 5 time(s)