Email contains Characters and Numbers

studio
variable
string

#1

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?


#2

Example: How to I search to make sure that Gªns does not pass through.


#3

Hi @DavidV32,

Please refer the below url, to validate the mail id is in valid format or not.

Check Format of Email Adddress

Regards,
Arivu


#4

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?


#5

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


Sample implementation for isMatch activity
#6

Right, I placed that in, but Gªns@xxx.yyy is still being read as a valid email.


#7

Hi @DavidV32,

its not considering special char,
“Gªns@xxx.yyy” its returning given mail is valid.

Regards,
Arivu


#8

Is there a way to check for the special characters to make sure that it does not register as a valid email?


#9

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.


#10

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?


#11

Hi @DavidV32,

@ClaytonM,

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


#12

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.


#13

Hi @ClaytonM,

I hope your regex expression will allow multiple@ and .(dot)

Regards,
Arivu


#14

Hi @DavidV32,

@ClaytonM

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


#15

check this