c# - Regular Expression to validate email -
this question has reply here:
using regular look validate email address 70 answers email validation - regular look [duplicate]using system; using system.collections; using system.collections.generic; using system.io; using system.text; using system.text.regularexpressions; namespace read_test { class stringcheck { static void main(string [] args) { string email = "email@email.com"; string regex = @"\w+\.?\w+\@{1}\w+\.{1}\w+"; match amatch; amatch = regex.match(email, regex); if (amatch.success) console.writeline("successfull."); else console.writeline("not successfull"); console.read(); } }
}
tried writing regular look check if email id entered valid. right? or there improve way
try this, dont need regex
bool isvalidemail(string email) { seek { var addr = new system.net.mail.mailaddress(email); homecoming true; } grab { homecoming false; } }
c#
No comments:
Post a Comment