Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is a long and complicated process to make a 100% accurate regular expression to validate email address, but, I have a good one with 2 bugs, it reports the following valid email addresses as invalid:

 

user@domain.museum (6 letter domain which is only museum?!)

user@1domain.com (domain cannot start with numbers!)

 

Since I am not familiar with regular expressions I want to know if anyone knows how to fix this 2 bugs? Please explain each of them separately so in case I don't want to use the 1st fix I can!

 

Dim AddressPattern As String = _

"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" & _

"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?" & _

"[0-9]{1,2}|25[0-5]|2[0-4][0-9])\." & _

"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?" & _

"[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" & _

"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...