RE: email regex?
Here's one I use at work: function validateEmail(vfld,displayName) { var tfld = trim(vfld.value); // value of field with whitespace trimmed off var email = /[EMAIL PROTECTED]@[EMAIL PROTECTED]@]*\w\w$/ if (!email.test(tfld)) { alertUser(ERROR: + displayname + is not a valid email address.); setfocus(vfld); return false; } return true; } -Original Message- From: Crow T. Robot [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 4:32 PM To: CF-Talk Subject: email regex? What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239235 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
email regex?
What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239187 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
I don't generally bother, because you can validate the hell out of it, but [EMAIL PROTECTED] will always work :) I just don't think it's worth the effort to validate. If you want to ensure that it's a 'good' address, automatically send them an e-mail to which they must respond...or i think there are some web services out there now that will ping a mail server to see if the email address exists. Just my $0.2. On 5/1/06, Crow T. Robot [EMAIL PROTECTED] wrote: What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239188 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: email regex?
cffunction name=IsEmail access=public returntype=boolean output=no hint=Determines if the given string is an email address !--- Define arguments. --- cfargument name=Text type=string required=yes / cfscript // Check to see if the text is an email address. Checking for an email // format is somewhat complicated so we will break it into several different // RegExp functions instead of trying to create some huge retarded script. if ( Len(ARGUMENTS.Text) AND // Must have a length. REFindNoCase([EMAIL PROTECTED],10}, ARGUMENTS.Text) AND // Checking for general format. [EMAIL PROTECTED] (NOT REFindNoCase((^(\.|-)), ARGUMENTS.Text)) AND // Doesn't start with '.'. (NOT REFindNoCase((\.{2,})|(-{2,}), ARGUMENTS.Text)) AND // Doesn't have two '.' or two '-' in a row. (NOT REFindNoCase(([\.\-]+@)|(@[\.\-]+)|(\.-)|(-\.), ARGUMENTS.Text)) // Doesn't have wierd combos of letters. ){ // This string is an email address. return(1); } else { // This string does not match a valid email address. return(0); } /cfscript /cffunction ... Ben Nadel www.bennadel.com -Original Message- From: Crow T. Robot [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 4:32 PM To: CF-Talk Subject: email regex? What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239189 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: email regex?
Oops, The one I sent was Sever side, but could be changed for client-side... ... Ben Nadel www.bennadel.com -Original Message- From: Crow T. Robot [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 4:32 PM To: CF-Talk Subject: email regex? What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239190 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
Yea, we're gonna do both, just trying to validate it a little bit before it makes it to the processing page. I just checked the livedocs and used that one. Thanks Charlie Griefer wrote: I don't generally bother, because you can validate the hell out of it, but [EMAIL PROTECTED] will always work :) I just don't think it's worth the effort to validate. If you want to ensure that it's a 'good' address, automatically send them an e-mail to which they must respond...or i think there are some web services out there now that will ping a mail server to see if the email address exists. Just my $0.2. On 5/1/06, Crow T. Robot [EMAIL PROTECTED] wrote: What's everyone's favorite regex for validating form-input email addresses on the client side? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239191 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
I have good luck with: isValid(email, form.emailAddr) What's wrong with that? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239195 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: email regex?
I haven't really gotten into that yet. My Email validator is pre MX7... But I gotta start using the IsValid() methods. ... Ben Nadel www.bennadel.com -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 5:14 PM To: CF-Talk Subject: Re: email regex? I have good luck with: isValid(email, form.emailAddr) What's wrong with that? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239196 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
Yea, me too. Most of my apps are MX7, but I havent' taken the time to look into the various possibility. Les, I was looking for client-side. But, no matter, I stole one from the livedocs that does a good enough job of keeping the trolls out. Ben Nadel wrote: I haven't really gotten into that yet. My Email validator is pre MX7... But I gotta start using the IsValid() methods. ... Ben Nadel www.bennadel.com -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Monday, May 01, 2006 5:14 PM To: CF-Talk Subject: Re: email regex? I have good luck with: isValid(email, form.emailAddr) What's wrong with that? ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239197 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
Charlie Griefer wrote: I don't generally bother, because you can validate the hell out of it, but [EMAIL PROTECTED] will always work :) yeah, but [EMAIL PROTECTED] won't break cfmail. Rick ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239199 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: email regex?
On 5/1/06, Rick Root [EMAIL PROTECTED] wrote: Charlie Griefer wrote: I don't generally bother, because you can validate the hell out of it, but [EMAIL PROTECTED] will always work :) yeah, but [EMAIL PROTECTED] won't break cfmail. True...i guess validation (or some sort of error handling) does need to be done someplace...either when collecting the address or prior to using it. -- Charlie Griefer ...All the world shall be your enemy, Prince with a Thousand Enemies, and whenever they catch you, they will kill you. But first they must catch you, digger, listener, runner, prince with a swift warning. Be cunning and full of tricks and your people shall never be destroyed. ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239202 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Email Regex with weird results
All: I've been using a regex found on this list to validate email addresses. I've now run into a problem with the regex that I can't solve.Any help would be greatly appreciated. The email address is not required so the field can either be left blank or must contain a valid email address.The regex validation code follows: CFIF (Len(Trim(FORM.Email)) NEQ 0) AND (REFindNoCase(^[a-zA-Z]([[:alnum:]\-_]+\.?)*@([[:alnum:]\-_]+\.)+[a-zA-Z]{2 ,4}$, FORM.Email) EQ 0) Email address is invalid /CFIF The email address is of the form [EMAIL PROTECTED] (that is, the domain contains a dash).If I remove the dash from the domain, the address validates.However, the dash should be valid. Looking at the regex, doesn't the ([[:alnum:]\-_]+\.) portion after the @ symbol allow for dashes? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: Email Regex with weird results
The - needs to be the very last character in the class. This is because the - in any other postion indicates a range of chars. so \-_ is saying\]^_ (which is the \ character to the _ character in the ascii table) Jerry Johnson [EMAIL PROTECTED] 07/01/04 11:56AM All: I've been using a regex found on this list to validate email addresses. I've now run into a problem with the regex that I can't solve.Any help would be greatly appreciated. The email address is not required so the field can either be left blank or must contain a valid email address.The regex validation code follows: CFIF (Len(Trim(FORM.Email)) NEQ 0) AND (REFindNoCase(^[a-zA-Z]([[:alnum:]\-_]+\.?)*@([[:alnum:]\-_]+\.)+[a-zA-Z]{2 ,4}$, FORM.Email) EQ 0) Email address is invalid /CFIF The email address is of the form [EMAIL PROTECTED] (that is, the domain contains a dash).If I remove the dash from the domain, the address validates.However, the dash should be valid. Looking at the regex, doesn't the ([[:alnum:]\-_]+\.) portion after the @ symbol allow for dashes? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email Regex with weird results
\- means no dashes! Paul [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: Email Regex with weird results
I use function IsEmail(str) { var sInvalidCharsPattern = [^[:alnum:[EMAIL PROTECTED]']; var sFormatPattern = ([a-z0-9][-._a-z0-9]*)[EMAIL PROTECTED]([a-z0-9][-_a-z0-9]*\.)+[a-z]{2,7}; var sStrippedEmail = REReplaceNoCase(Trim(str), sInvalidCharsPattern, , ALL); str = Trim(str); if (Len(str) EQ Len(sStrippedEmail)) return IIF(REFindNoCase(sFormatPattern, str) EQ 1, true, false); else return false; } which allowed the - HTH Mike On Thu, 1 Jul 2004 11:56:23 -0400, Mosh Teitelbaum [EMAIL PROTECTED] wrote: All: I've been using a regex found on this list to validate email addresses. I've now run into a problem with the regex that I can't solve.Any help would be greatly appreciated. The email address is not required so the field can either be left blank or must contain a valid email address.The regex validation code follows: CFIF (Len(Trim(FORM.Email)) NEQ 0) AND (REFindNoCase(^[a-zA-Z]([[:alnum:]\-_]+\.?)*@([[:alnum:]\-_]+\.)+[a-zA-Z]{2 ,4}$, FORM.Email) EQ 0) Email address is invalid /CFIF The email address is of the form [EMAIL PROTECTED] (that is, the domain contains a dash).If I remove the dash from the domain, the address validates.However, the dash should be valid. Looking at the regex, doesn't the ([[:alnum:]\-_]+\.) portion after the @ symbol allow for dashes? TIA [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email Regex with weird results
Jerry (and everyone else): Thanks. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ Jerry Johnson [mailto:[EMAIL PROTECTED] wrote: The - needs to be the very last character in the class. This is because the - in any other postion indicates a range of chars. so \-_ is saying\]^_ (which is the \ character to the _ character in the ascii table) Jerry Johnson [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Email Regex with weird results
All: I've been using a regex found on this list to validate email addresses. I've now run into a problem with the regex that I can't solve.Any help would be greatly appreciated. The email address is not required so the field can either be left blank or must contain a valid email address.The regex validation code follows: CFIF (Len(Trim(FORM.Email)) NEQ 0) AND (REFindNoCase(^[a-zA-Z]([[:alnum:]\-_]+\.?)*@([[:alnum:]\-_]+\.)+[a-zA-Z]{2 ,4}$, FORM.Email) EQ 0) Email address is invalid /CFIF The email address is of the form [EMAIL PROTECTED] (that is, the domain contains a dash).If I remove the dash from the domain, the address validates.However, the dash should be valid. Looking at the regex, doesn't the ([[:alnum:]\-_]+\.) portion after the @ symbol allow for dashes? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email Regex with weird results
I think you just need to modify the domain check a little bit... [[:alnum:]\-_] Should be [[:alnum:]_-] Otherwise you're matching everything between '\' and '_'. The ASCII sequence this matches is \[^_ Presumably you want to allow only alpha numeric, _ and - in the domain name. Spike Stephen Milligan Code poet for hire http://www.spike.org.uk Do you cfeclipse? http://cfeclipse.tigris.org -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mosh Teitelbaum Sent: Thursday, July 01, 2004 6:57 AM To: CF-Talk Subject: Email Regex with weird results All: I've been using a regex found on this list to validate email addresses. I've now run into a problem with the regex that I can't solve. Any help would be greatly appreciated. The email address is not required so the field can either be left blank or must contain a valid email address.The regex validation code follows: CFIF (Len(Trim(FORM.Email)) NEQ 0) AND (REFindNoCase(^[a-zA-Z]([[:alnum:]\-_]+\.?)*@([[:alnum:]\-_]+\ .)+[a-zA-Z]{2 ,4}$, FORM.Email) EQ 0) Email address is invalid /CFIF The email address is of the form [EMAIL PROTECTED] (that is, the domain contains a dash).If I remove the dash from the domain, the address validates.However, the dash should be valid. Looking at the regex, doesn't the ([[:alnum:]\-_]+\.) portion after the @ symbol allow for dashes? TIA -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email Regex with weird results
Stephen Milligan [mailto:[EMAIL PROTECTED] wrote: I think you just need to modify the domain check a little bit... [snip] Thanks. Actually, this message got posted twice and I already received an answer. Basically the same as yours. 8^) Thanks again. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email Regex with weird results
Ah, Just re-joined the list, so I must have missed the previous post. Spike Stephen Milligan Code poet for hire http://www.spike.org.uk Do you cfeclipse? http://cfeclipse.tigris.org -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mosh Teitelbaum Sent: Thursday, July 01, 2004 11:56 AM To: CF-Talk Subject: RE: Email Regex with weird results Stephen Milligan [mailto:[EMAIL PROTECTED] wrote: I think you just need to modify the domain check a little bit... [snip] Thanks. Actually, this message got posted twice and I already received an answer. Basically the same as yours. 8^) Thanks again. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: Email regex
Jeff, that regexp works for me. I would be interested in seeing something similar for URL's -- I have been experimenting but got stuck. Something like: REREPLACE(String,((http:\/\/|www\.|WWW\.)[^[:space:]]+)([[:space:]]|\.), A HREF=\1\1/A\3,ALL) (Two problems with the above one: it doesn't add http:// in front of links that miss that, and it includes trailing dots (like a link at the end of a sentence)). - Hugo Ahlenius E-Mail: [EMAIL PROTECTED] Project Officer Phone: +46 8 7410451 UNEP GRID-Arendal Fax: +46 733 403285 Stockholm OfficeMobile:+46 733 467111 WWW: http://www.grida.no - | -Original Message- | From: Jeff Green [mailto:[EMAIL PROTECTED]] | Sent: Wednesday, July 24, 2002 03:36 | To: CF-Talk | Subject: Email regex | | | Hi all, | | Im working on a regular expression for matching an email. | | So far I have this: | [-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0-9]+)+ | | used like this: | CFSET EmailPos = | REFindNoCase([-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0- | 9]+)+,From,1, | True) | | I swear ive used this before and it worked, although now only | the .com or | the .net is matching. | | Any ideas, | Jeff | __ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Email regex
This was discussed recently and the following RegEx was recommended. It also supports the new top level domains. CFSET MyEmail = [EMAIL PROTECTED] CFIF REFindNoCase(^['_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a- z]{2,3})|(aero|coop|info|museum|name))$,MyEmail) Valid email CFELSE Invalid email /CFIF Chris Lofback Sr. Web Developer TRX Integration 28051 US 19 N., Ste. C Clearwater, FL 33761 www.trxi.com -Original Message- From: Jeff Green [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 9:36 PM To: CF-Talk Subject: Email regex Hi all, Im working on a regular expression for matching an email. So far I have this: [-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0-9]+)+ used like this: CFSET EmailPos = REFindNoCase([-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0-9]+)+,From,1, True) I swear ive used this before and it worked, although now only the .com or the .net is matching. Any ideas, Jeff __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Email regex
Hi all, Im working on a regular expression for matching an email. So far I have this: [-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0-9]+)+ used like this: CFSET EmailPos = REFindNoCase([-A-Za-z0-9_\.]+[@][-A-Za-z0-9_]+([\.][-A-Za-z0-9]+)+,From,1, True) I swear ive used this before and it worked, although now only the .com or the .net is matching. Any ideas, Jeff __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists