UiPath email regex explaination?

Can anyone explain this regex used to get the email address? It is given in the ‘Matches’ activity.

((?>[a-zA-Z\d!#$%&'*+\-\/=?^_{|}~]+\x20*|"((?=[\x01-\x7f])[^"\]|\[\x01-\x7f])"\x20)(?<))?((?!.)(?>.?[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)>)

1 Like

Hi @kumar.varun2

Actually regex pattern provided by uipath is seems to be matching each kind of email being present in string, it is some kind of u can say a Machine Learning [not really], where bot is applying all kind of combinations to extract the email from any given data , as u can see there is | symbol that actually signifies the or in regex pattern, so if one pattern fails, other pattern will check it and so on…

For a simple email like nived@gmail.com u can use a regex pattern like [\S]+@[\S]+
to extract the email data, but it may be matching to one particular type actually here when u use the regex pattern

Hope the explanation helps you

Regards,
Nived N
Happy Automation

@kumar.varun2
Refer this post:

There’s a website called https://regexr.com/, where you can paste this regex, select PCRE server in the regex engine(top right beside flags button). Then it gives explanation about most of the parts of the regex