Regexes

Hi I need to read data from Email, I dont know how to create regex. I have something like:
System.Text.RegularExpressions.Regex.Match(EmailBody,"(?<=QuoteNumber).+").Value
and it works for only for th first row:

Email:
QuoteNumber : 123

SAP ID of Account : 123

SAP ID of Channel Partner : 123

SAP ID of Sold To : 123

How to make it work for other rows as well?

when anchoring to a particular value like:
grafik

then sure it is working only for this anchor

when making it generic to all values after : then it looks like this:
grafik

But if the field info is needed we need more extraction info. e.g. like:
grafik

and consult the groups:
grafik

also have a look here:

Yee but then I need to use Matches and then assign. If I want to use only assign in multiple assign how to create such regex?

System.Text.RegularExpressions.Regex.Match(EmailBody,"(?<=SAP ID of Account : ).+").Value
doesnt work :frowning:

Regex Megapost and referenced learning resources are very recommended it newe/newr to regex

We use matches if we expect also mutliple hits within the text
grafik

here we are looking for a single digit and got 3 hits

We use Match if we are expecting /are interested on only max 1 hit:
grafik

So it depneds on your strategy wehen to use match or matches

Kindly note: when importin following we can reduce the statement as seen in imediate boxes above:
grafik

Yes sure, but in this page it looks like it should be working: image

not sure If I got the questions

Match is 123, SAP ID of Account is Anchor and therefore not part of the match

ok, that is right but I mean that regex in Uipath returns me QuoteNumber as well.

In my example they are all 123 but I want to get the value from SAP ID of Account, not from the first one.

I’m just kindly asking You to help me fixing this regex :frowning:

I have sth like this
image

we cant see the implementation details. e.g. Regex Patterns. Please share all infos with us. thanks

OK, I have such email body and I need to read 4 variables from it

"QuoteNumber : 123

SAP ID of Account : 345

SAP ID of Channel Partner : 567

SAP ID of Sold To : 897"

For that I use multiple assign.
out_QuoteNumber = System.Text.RegularExpressions.Regex.Match(EmailBody,"(?<=QuoteNumber : ).+").Value

that gives me result “123”

out_AccountSapId = System.Text.RegularExpressions.Regex.Match(EmailBody,"(?<=SAP ID of Account : ).+").Value
that doesnt give me “345”

You get it?

I just want to read values : “123”, “345”, “567”, “897” into different variables in my multiple assing activity.

@jeyekij306 - Is this what you are looking for??

@ppr has already provided the solution for this in his post.

A kind request, next time before completing your testing do not mark the post as solution.

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