How to validate phone number and email using regex

Hi Guys,

I have to get email ids and phone numbers both from queue , i want to validate that format of email and phone number.

I need to validate phone and email if suppose invalid format came i ill put exception .

Please help me anyone out from this.

Excepted format:
email:abc@gmail.com
phone:1234567890

Regards,
Raja G

Hi @Raja.G

In matches activity itself they have give the regex pattern for email (click configure in matches activity and it will be found in the drop-down) and for email,this will work,

\d{10}

Thanks

Hi,

How about the following pattern?

"email:((?>[a-zA-Z\d!#$%&'*+\-\/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-\/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)"


"phone:\d{10}\b"

Regards,

Hi @prasath_S @Yoichi ,

i did separate validation i want bot are same “Ismatch” for regex

And result whatever wrong format i want to send exception if phone i want to send phone number invalid if email invalid i want to send invalid email.

Test1.xaml (27.6 KB)

Hi,

Can you try the following settings for IsMatch activity?

Input : phonenumber+chr(9)+Email

Pattern:

 "^\d{10}\t((?>[a-zA-Z\d!#$%&'*+\-\/=?^_`{|}~]+\x20*|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*""\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-\/=?^_`{|}~]+)+|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*"")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)"

Regards,

@Yoichi

how to identify what format error? like phone or email

Hi @Raja.G

You can use try catch block for both email and phone format checks as you want to find out which one fails. In the catch block you can throw exception and assign a variable to identify which format is failed.

Thanks,
Boopathi.

Hi,

It’s difficult to identify from single IsMatch activity. If we need to know which string is error, it’s better to use 2 IsMatch activities.

Or do you want to use loop and IsMatch activity?

Regards,