Flow Decision with RegEx

Hello Community.

I have a list with lots of restaurants, which I want to find each possible menu card of it.
Therefore, I have made the following flowchart.

Extractin’ the information, I do a For Each run in my browser.

The restaurant name will be typed into the google search and filtered as pdf.
I have extracted the aaname of each google result and want to chouse the best match.

For the best match up with the results I have done some RegEx Flow Decision, If these are true, the Click activity should chouse and click on it.

I have made multiple Flow Decision IF for example the first match with

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:Menu|menu).+(?:Card|card)") or System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:Menucard|menucard)")

is not true. To chouse ne next best alternativ match which is:

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:Restaurant|restaurant)") or System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:Menu|menu)").

Unforunatly Uipath is not clicking on anything. Even when the results match up.

Also a screenshot of the Click Selector

What I have to change, so that the flowchart works?

thanks in advance!

Hi, at first try to minimize code, for eg.:

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname.ToUpper,"(?:MENU|CARD|MENUCARD).+")
System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname.ToUpper,"(?:RESTAURANT|MENU).+")

Or

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)
System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:RESTAURANT|MENU).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

When clicking, you should probably insert the downloaded attribute:

Attribute of innerText:

Hi @Adrian_Star

I change my code to System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

and instead of the ‘aaname’ I choused the ‘innertext’ and it worked!

You mentioned

should i connect these two with an ‘and’/‘or’.
Because writing it underline like:
1. System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)
2. System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:RESTAURANT|MENU).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)
will get me an error!

So when I have a search pattern, which have multiple key words and combinations in it. Can I add some combinations in one Flow Decision and combine them with:
System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase) AND
System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:RESTAURANT|MENU).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

or should I take each one of them in one container and combine multiple Flow Decision in the right pattern?

Thank you very much!

Use as many conditions as you need to handle the case. I don’t know what your process’s workflow looks like, but if you want to combine 2 regex checks in one decision, maybe it’s better for you to combine them into:

(OR Equivalent):

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD|RESTAURANT).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

(AND Equivalent):

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase) And System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:RESTAURANT).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

If your process is to be prepared for a different type of click depending on the RegEx check, then you can use the FLOW SWITCH activity. It is there to handle many cases (it’s such multiple FLOW DECISIONS in one block):

Eg.:


After doing a full process, I noticed that the activity always choses the first result as an match. Even If the match dosn´t fit the condition.
I tried with the Flow Switch aswell and still get the first google match only.

Alos, Im not so familiar with RegEx, Is it possible to add a NOT Match condition. For Example If I want a match with “Restaurant” “menucard” and Not with “Burger”.
I read about the following RegEx condition to be a Not Match “/^((?!BURGER)[\s\S])$/*”.
So would it be possible to add the following context as an condition like the one before just with:

“…System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,”/^((?!BURGER)[\s\S])$/",System.Text.RegularExpressions.RegexOptions.IgnoreCase)"*

Yes, you can do False condition:

Not System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Or:

System.Text.RegularExpressions.Regex.IsMatch(getattributeaaname,"(?:MENU|CARD|MENUCARD).+",System.Text.RegularExpressions.RegexOptions.IgnoreCase) = False
1 Like

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