Search code examples
regexswiftemail-validationnsregularexpression

how to obtain a regular expression for validation email address for one domain ONLY?


I am struggling with writing a regex for validating email address for only one domain.

I have this expression

[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}

But the issue is that for example [email protected] is valid and I only want to be only valid for only one domain. So hence I do not want [email protected] to be valid.

Help is needed. Thank you!


Solution

  • try this [A-Z0-9a-z._%+-]+@[A-Za-z0-9-]+\.[A-Za-z]{2,64}. In your regex is a dot in the allowed characters behind the @.