Regular expression to check that a specific email domain is being used.

Our organization has more than one email domain. On an internal web app, I want employees to register/update ONLY with a particular domain...

What would a regex look like that says they can put any username, but the domain MUST be @dallasray.com?
LVL 2
smetterdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

silemoneCommented:
[a-zA-Z0-9]+[@][dallasray]\.com
0
silemoneCommented:
[a-zA-Z0-9]+[@][dallasray]\.com$            forgot $ for end of line make sure it ends after com
0
ddrudikCommented:
seems a job for string functions in the programming language you are using, but if it needs to be regex:
.*@dallasray\.com$

Set case-insensitivity in the regex object.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

silemoneCommented:
the regular expression i supplied said username must have at least one character that is a capital letter, number, or lowercase letter, but can have many more....if you have a limit then you can set that also...but you didn't supply one yet...
also

so here are some addresses that would work:

1@dallasray.com
1000@dallasray.com
aA@dallasray.com
a111@dallasray.com

if you want to be all alphabets, remove 0-9  which means all numbers between 0-9

if you want it to start with a letter   then


[a-zA-Z][a-zA-Z0-9]*[@]dallasray\.com

oops and remove brackets from around dallasray in all my examples...that was a typo..

0
silemoneCommented:
ddrudik...

.* would allow the user to have a username like ?++--;;;'''???@#??#?@?@dallasray.com  which would be hard to store in a database...


that's why you would use [a-zA-Z0-9]...etc...
0
silemoneCommented:
smet, did you read my last post...you will get bad usernames if you use .*...anyway, to each there own....

good luck...obviously, you're still free to use my examples though you awarded points to ddrudik...
cheers


0
ddrudikCommented:
smetterd, thanks for the question and the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.