Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression 1

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary user)

Hello,

Can anyone help me with the correct syntax for a regular expression?

Part of the script I am writing must evaluate the user's email address against a regular expression and it must be:

'any user' @ 'any country' followed by 'acme.com':

someuser@country.acme.com

[A-Za-z0-9._%+-]+@[A-Za-z]+\.[acme]{4}+\.[com]{3}

Is my approach correct?

Best regards

 
Can they really have all of those symbols in their username?

For the latter part you should just use \.acme\.com$, otherwise "came.moc" would also match (not that anyone is likely to try that, but...). The $ ties it to the end of the string to prevent them adding .xx country codes to the end. You should probably also prefix the entire thing with ^ as well to tie it to the beginning.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Thank you so much; I tried it out immediately and it works fine!

Best regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top