Reply
is string an email address
Old 02-28-2008, 07:24 PM is string an email address
Skilled Talker

Posts: 92
I need a script that tells you if a string is a valid email address.

contains one "@" symbol, and has at least one period after the "@" symbol.
Skeddles is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-28-2008, 07:30 PM Re: is string an email address
tripy's Avatar
Fetchez la vache!

Posts: 2,057
Name: Thierry
Location: In the void
This is a simple function I have been using in PHP for years.
Feel free to derive it in asp:
PHP Code:
function is_email($e){
// returns true if it's an email address.
// returns false if it's not.
  
if (eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$"$e)==1){   
    return 
true;
  }
  else{
    return 
false;
  }

__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 02-28-2008, 07:32 PM Re: is string an email address
chrishirst's Avatar
Super Moderator

Posts: 13,658
Location: Blackpool. UK
Code:
function CheckMail(strIn)
 dim objRE
  Set objRE = New RegExp
  objRE.Pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
  objRE.IgnoreCase = true
  CheckMail = objRE.Test(strIn)
set objRE = Nothing
end function
or a dead simple one

Code:
function CheckEmail(strEmail)
dim temp
temp = false
if len(strEmail) > 6 then temp = true
	if temp then 
		if (instr(strEmail,"@") < 2 or instr(strEmail,".") = 0) then
			temp = false
		else
		if instr(instr(strEmail,"@"),strEmail,".") = 0 then
			temp = false
		end if		
		end if
	end if
CheckEmail = temp 
end function
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-28-2008, 07:34 PM Re: is string an email address
chrishirst's Avatar
Super Moderator

Posts: 13,658
Location: Blackpool. UK
How about that for efficiency?

converted from PHP to ASP in under two minutes
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-28-2008, 07:46 PM Re: is string an email address
tripy's Avatar
Fetchez la vache!

Posts: 2,057
Name: Thierry
Location: In the void
Good work Chris !
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 02-28-2008, 08:42 PM Re: is string an email address
Skilled Talker

Posts: 92
Thank you!
Skeddles is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to is string an email address
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12868 seconds with 12 queries