How to retrieve only this INC12345678 in the mail body of an email?

INC text size is same = 11 always,
but issue is it is retrieving anything starts with INC.
If anyone can suggest how to only retrieve INC succeeded with only digits i.e. INC12345678 from below body?
Please help!

I’ve used below code:

mailBody.substring(mailbody.indexOf(“INC”),11)


MailBody is below:

Hi,

abcdef

Regards,
Incidiya Arora

INC12345672

Regards,
Arora

Hi

We can try with Regex expression

To use this expression in UiPath use a assign activity like this

Let’s take you have the input in Strinput
Then in assign activity

Stroutput = System.Text.RegularExpressions.Regex.Match(Strinput.ToString,”(INC).+”).ToString

Cheers @anjasing

Are u sure it will take only 11 digits and will only INC succeeding with digits? Let me check

1 Like

If you want along with INC and the following digits then above expression
Or

If you want to have only the digit after INC

Then this expression

Stroutput = System.Text.RegularExpressions.Regex.Match(Strinput.ToString,”(INC).+”).ToString.Replace(“INC”,””)

Cheers @anjasing

1 Like

Hey @anjasing

This regex should slove your query: [1]*\d{8}

System.Text.RegularExpressions.Regex.Match(Strinput.ToString,”[2]*\d{8}”).ToString

Hope this helps


  1. INC ↩︎

  2. INC ↩︎

1 Like

in Addition to:

And

let the string start by INC following by numbers and give try on following pattern
INC\d+
INC\d{8}\b - restricting digits on a length of 8
(?<=INC)\d+ - Anchoring on INC and extracting only the number


  1. INC ↩︎

1 Like

This worked INC\d{8}\b and was a small solution. Thank you so much,
Thank you all for your help :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.