Regex Need for following scenario

I received string in body of email and i extract that as a string from that sring i need to etract To mail id and CC mail id using Regex.

**To: aa bb; E K; P Z; P P; A A; **
Cc: M B

Here i need two regex

1 To Mail address o/p like,

Then another regex
cc mail id

Vicky K


are stars and all are part of the string you get?

if yes then first split using Cc: arr_String = str.Split({"Cc:"},StringSplitOptions.None)

str is the string variable where the strng is stored

arr_string is the array output

now to get all to fields use this…which will add add the values extracted with Newline character and give as one string

tovalues = String.Join(Environment.NewLine,System.Text.RegularExpressions.Regex.Matches(arr_String(0),"[^ ]+(?=@)[^ ;]+"))

ccvalues = String.Join(Environment.NewLine,System.Text.RegularExpressions.Regex.Matches(arr_String(1),"[^ ]+(?=@)[^ ;]+"))

Hope this helps



Can you try the following sample?

Sample (2.7 KB)


Hi @Vicky_K ,
Thanks for reaching out to UiPath Community.

Here are the regexpattern that you can use.
Extract To Email Address: To: (.?@.?:wink:
Extract CC email Address: Cc: (.@.)


i received o/p using above one but still i have
but i don’t want <> this one i need only mail id like this


Can you please show a screenshot of what you are getting

may be you typed something but not able to see …try usign performatted text (</>)


Hi @Vicky_K

Split the text:

parts = inputText.Split({"Cc:"}, StringSplitOptions.RemoveEmptyEntries)
toPart = parts(0).Trim()
ccPart = parts(1).Trim()

Regex for toPart and ccPart:

System.Text.RegularExpressions.Regex.Matches(toPart, "(?<=[:|;]\s\w+\s\w+\s)\w+\.?\w+\@\w+.\w+")
System.Text.RegularExpressions.Regex.Matches(ccPart, "(?<=[:|;]\s\w+\s\w+\s)\w+\.?\w+\@\w+.\w+")

Or you can use this also "\w+?[.]?\w+@\w+.\w+" instead of above


Input: **To: aa bb; E K; P Z; P P; A A; **

You can try this regex expression it will work for both the To and CC values

RegexExpression : - [A-Za-z@.]+(?:com)