Print Page | Close Window

who understands objRegExp?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1712
Printed Date: 29 March 2026 at 7:40pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: who understands objRegExp?
Posted By: vicky_c
Subject: who understands objRegExp?
Date Posted: 09 April 2003 at 9:33am

Hope someone can help....

I have recently set up a log in thingy to my website as part of a project and on the join up form have used objRegExp in the validation for the user inputted e-mail address (a recomendation from one of you lovely lot!) and its working great! so thanks a lot! <img border=0 onclick="AddSmileyIcon('smileys/smiley4.gif')" src="http://forums.webwiz.net/smileys/smiley4.gif" style="CURSOR: hand">

Only thing is, I need to write an alogorithm for this particular part of the coding and fully refine it.  So, does anyone who completly understands the objRegExp thingy know how to write an algorithm for these few lines? <img border=0 onclick="AddSmileyIcon('smileys/smiley5.gif')" src="http://forums.webwiz.net/smileys/smiley5.gif" style="CURSOR: hand">

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CheckMail(Email)

Function CheckMail(Email)
Dim objRegExp , blnValid
Set objRegExp = New RegExp
objRegExp.Pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
blnValid = objRegExp.Test(Email)
If NOT blnValid THEN Response.Redirect "invalid.asp"
End Function

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It may seem like a stupid question but I really don't wanna mess this up!  The algorithm is worth a lot of marks and it needs to be perfect! My whole life depends on it! literally! i need to pass this subject to get into Uni!! lol!

So please help....I'm so grateful!!!!!!

Loadsa love and bubbles,
Vicky <img border=0 onclick="AddSmileyIcon('smileys/smiley1.gif')" src="http://forums.webwiz.net/smileys/smiley1.gif" style="CURSOR: hand"> xxx




Replies:
Posted By: glypher
Date Posted: 09 April 2003 at 12:51pm

code is fine, but personally i wouldn't stick the redirect in the validation code.

for example:

if the function was named IsValidEmail(), the function could return a true or false.  and based on that you could decide to redirect.

==================================

Email = "ThisIsATest@myhome.com"

response.write email & " is "

if IsValidEmail(Email) then
response.write "Valid"
else
response.write "Invalid"
end if

Function IsValidEmail(Email)
  Dim objRegExp , blnValid
  Set objRegExp = New RegExp
  objRegExp.Pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
  IsValidEmail = objRegExp.Test(Email)
End Function

==============================



-------------
glypher said so.

http://www.gainesvillebands.com - GainesvilleBands.com


Posted By: vicky_c
Date Posted: 09 April 2003 at 12:54pm

Oh...em ok thanks!

Any idea how I could write the algorithm?



Posted By: glypher
Date Posted: 09 April 2003 at 1:39pm

what do you mean by "write the algorithm?"



-------------
glypher said so.

http://www.gainesvillebands.com - GainesvilleBands.com


Posted By: Coco Brown
Date Posted: 16 April 2003 at 12:38pm

I would advise against validating an email to see if it is the correct format.  Even with a regex pattern.

I thought I had the perfect regex for email, but kept getting burned because someone outside my country of origin would show up with some email format I hadn't accounted for.

One day, I decided to get the penultimate regex for email.  I followed it to a Perl site that had this very famous pattern created by a CS professor from MIT.  He said it was foolproof.  The regex was about 800 lines long and took 3 hours to execute.  The point that this professor was trying to make is that there is only a very, very loose protocol defining how an email address should be formatted, so validating for proper format for an email is pointless.  There is no real algorithm for doing the job.  If you absolutely must know if an email is valid, the best practice is still to send a confirmation email to the address.  




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net