Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Prescription for Regularity ?

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2005-03-03 : 08:01:07
I don't deal with regular expressions often. I hope there's someone out there with the right prescription

Since my recent move from CDONTS to CDOSYS, I found that the way I previously supported friendly email addresses:

(John Doe) john.doe@mydomain.com

doesn't appear "neat" any longer. Recipients used to receive email that read:
From: John Doe
but now read as:
From: John Doe <john.doe@mydomain.com> john.doe@mydomain.com

I'm not sure if this started with CDOSYS or not, but I did come across another way of coding the email:

John Doe <john.doe@mydomain.com>

which appears in the recipient's email as:

John Doe <john.doe@mydomain.com>

slightly better (but not "John Doe" exactly. This is another issue, but I can live with it). This brings me to the problem. I'm a novice at regular expressions. This expression:

^(\(.*\))?\s*[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$ 


will validate my original email syntax: (optional name) john.doe@mydomain.com

I need to find a new regular expression which will validate the new email syntax which has any of 3 forms:

John.doe <john.doe@mydomain.com>
<john.doe@mydomain.com>
john.doe@mydomain.com

Any regular expression sharpies out there?

Thanks.

Sam

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-03 : 08:05:42
this is where you wanna look:
http://www.regexlib.com/DisplayPatterns.aspx

Go with the flow & have fun! Else fight the flow
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-03-03 : 08:06:35
Try here:

http://regexlib.com/

They have a menu at the top called "Patterns", and there is an Email section in there that has more email patterns than you could possibly imagine.

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-03 : 08:07:46
...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-03-03 : 08:37:06
I'm feeling much better now !
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-03 : 08:42:37
glad we cured you of your "bad feeling".

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2005-03-03 : 18:02:31
Don't know if you've seen this :

http://www.gotdotnet.com/workspaces/workspace.aspx?id=01e0dfb7-0182-45cd-94f7-2ed2df2504a9

My fave tool for writing and debugging Regexes.

Get down with your bad feelings



Damian
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2005-03-04 : 12:37:34
Damian,

Thanks for the tool. I tried it out, and it's easier to use than ASP and a debugger to test a regex.

Sam
Go to Top of Page
   

- Advertisement -