Write a simple regex for email validation? (C# interview questions with answers)
- By Shiv Prasad Koirala in C#
- Mar 24th, 2014
- 9200
- 0
Before reading the interview answer, please go through this Regex video to understand fundamentals of regex with c#.
Email validation can be divided in to three part the first is email user name , domain name and the domain extension.
Step 1(Email user name):- Email user name can start with alphanumeric with minimum 1 character and maximum 10 character. , followed by at the rate (@).
^[a-zA-Z0-9]1,10}@
Step 2 ( Domain name) :-The domain name after the @ can be alphanumeric with minimum 1 character and maximum 10 character , followed by a "."
[a-zA-Z]1,10}.
Step 3 ( Domain extension):-Finally should end with .com or .org
.(com|org)$
The final full email regex validation is below.
^[a-zA-Z0-9]1,10}@[a-zA-Z]1,10}.(com|org)$
Please visit www.questpond.com for 600+ C#/.NET interview questions and answers videos.
Watch our latest video on C# interview questions & answers :-
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more