How to validate a email address from text through regular expression in C#

Опубликовано: 19 Март 2026
на канале: IT Core Soft
64
1

Download from these link: https://github.com/hamza3344/emailche...
My fiverr link: https://www.fiverr.com/hamzakhalid178
My Upwork Profile: https://www.upwork.com/freelancers/~0...

Whatsapp Number: +923338672398

Regular Expression for email: [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

if you have any problem comment below. please like, share and subscribe the channel. Contact me on [email protected] if you need any custom software, website and mobile Application.

code

using System.Text.RegularExpressions;

string str = "if you care@domain [email protected] have contact@ any problem comment below. please [email protected] like, share and subscribe the channel. [email protected] Contact me on [email protected] if you need any custom software, website and mobile Application.";
var regex = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
var r = regex.Matches(str).Cast Match().Select(m =gt; m.Value).ToArray();
foreach(string s in r)
{
MessageBox.Show(s);
}