Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



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

Posts: 176
Trades: 0
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
 
 
Register now for full access!
Old 02-28-2008, 08:30 PM Re: is string an email address
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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;
  }

__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-28-2008, 08:32 PM Re: is string an email address
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-28-2008, 08:34 PM Re: is string an email address
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
How about that for efficiency?

converted from PHP to ASP in under two minutes
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-28-2008, 08:46 PM Re: is string an email address
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Good work Chris !
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-28-2008, 09:42 PM Re: is string an email address
Extreme Talker

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.22623 seconds with 12 queries