Last post Apr 05, 2017 01:10 PM by tvb2727
Apr 04, 2017 08:20 PM|tvb2727|LINK
I am seeing an issue with a regex where it will not allow a
firstname.lastname@example.org. So the dash is causing the regex to fail.
My regex: ^(?!.+my\.company\.org)[\w.]+@[\w.]+\.org$
So this is what it does:
It doesn't allow an email address to end in "@my.mycompany.org" AND it makes sure the email ends in ".org".
Now I need to make sure this works:
email@example.com works as well with the regex above.
Apr 05, 2017 09:31 AM|Cathy Zou|LINK
For your problem, I use the following code:
using System.Text.RegularExpressions; TextBox1.Text = "firstname.lastname@example.org";
Regex regex = new Regex(@"^(?!.+my\.company\.org)[\w.+\-\w.]+@[\w.]+\.org$");
Match match = regex.Match("email@example.com");
Apr 05, 2017 01:10 PM|tvb2727|LINK
Worked like a charm