?
Solved

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

Posted on 2008-11-12
7
Medium Priority
?
1,493 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:smetterd
  • 5
  • 2
7 Comments
 
LVL 21

Expert Comment

by:silemone
ID: 22943022
[a-zA-Z0-9]+[@][dallasray]\.com
0
 
LVL 21

Expert Comment

by:silemone
ID: 22943028
[a-zA-Z0-9]+[@][dallasray]\.com$            forgot $ for end of line make sure it ends after com
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 2000 total points
ID: 22943042
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 21

Expert Comment

by:silemone
ID: 22943069
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
 
LVL 21

Expert Comment

by:silemone
ID: 22943095
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
 
LVL 21

Expert Comment

by:silemone
ID: 22943162
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
 
LVL 27

Expert Comment

by:ddrudik
ID: 22943204
smetterd, thanks for the question and the points.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question