Is there a way to check if an email contains only letters and numbers (no special characters besides the @ and .) without having to check for them individually?
Example: How to I search to make sure that Gªns does not pass through.
Hi @DavidV32,
Please refer the below url, to validate the mail id is in valid format or not.
Check Format of Email Adddress - #2 by arivu96
Regards,
Arivu
When I ran the test it is claiming that it is a valid email, however, the program that I am load the email to does not like the special “a” character, or probably any special characters. Do you how if your check in UiPath is viewing it as a standard “a” and not a special character?
Hi @DavidV32 ,
use Is Match activity
In Properties
input string ->“arivu@xxx.yyy
2.Pattern ->”^([\w.-]+)@([\w-]+)((.(\w){2,3})+)$"
3.Result->(Boolean value)
you can verify the email id is correct format or not based on this Boolean value
Regards,
Arivu
Right, I placed that in, but Gªns@xxx.yyy is still being read as a valid email.
Hi @DavidV32,
its not considering special char,
“Gªns@xxx.yyy” its returning given mail is valid.
Regards,
Arivu
Is there a way to check for the special characters to make sure that it does not register as a valid email?
Maybe if you use Regex.
if System.Text.RegularExpressions.Regex.Match(text, "[^\w\d]+").Value.Trim = ""
If the above is true and the Match is “”, then there are no specials.
I hope that helps, and I have not tested the above.
Regards.
So this is coming back false. I’m assuming due to the @ and . caracters that are common in emails.
Is there a way to only allow the @ and . characters?
Hi @DavidV32,
bool IsValidEmail(string email)
{
try {
var addr = new System.Net.Mail.MailAddress(email);
return true;
}
catch {
return false;
}
}
Try this code to check the mail is valid or not.
Regards,
Arivu
You might also be able to add “@” and “.” in the brackets in the pattern.
if System.Text.RegularExpressions.Regex.Match(text, "[^\w\d\@\.]+").Value.Trim = ""
I like @arivu96’s idea too though to create an email address type, and it will throw an error if it’s not an email address.
Hi @DavidV32,
in uipath i checked “ª” its not considering as special character, if you want to remove that character before checking valid mail using replace function can do.
Else if “ª” comes means u need as invalid mail means before checking validation can check contains in that string , if suppose found we can assign as invalid mail
Regards,
Arivu