Wildcard Operators within Array of Type String?

Greetings,

I would have thought this would be simple, but it doesn’t appear so…

I am using a For Each Excel Row, and for each row, at CurrentRow.ByIndex(0), it is reading what is in the cell, and then performing a send hotkey action based on what is inside.

So,

Using Assign activity,
arrHardware = {“A*”, “B*”, “C*”}

Then using an If activity,

Condition =arrHardware.Any(Function (x) CurrentRow.ByIndex(0).toString.ToUpper.Contains(x.ToUpper))

So, if there is for example “Apple” in the excelcell, the wildcard operator would take care of the “pple” and read it as “A”.

It doesn’t look like this is working though. Doing a little bit of reading, it looks like I may need to use regex? I see wildcard operators for selectors, but for arrays it seems a bit different.

Always appreciate the quick and amazing help on here!

the contains method offered for a collection e.g. array is not supporting Wildcards and is using the item value - e.g. A*

We can implement such check with alternates, but would recommend to crosscheck the use case / scenario before

arrHardware = {“A*”,“B*”…}
as described in your flow would/should have a match on “The new Apple IPhone” for A* - Apple
But it would also match “Pay with American Express” - A* American

Maybe we have misinterpret your case and you can eleaborate more on it. Thanks

Peter,

Great to see you again. Thank you for suggesting we examine the use case more in depth.

I was using {“A*”, “B*”, “C*”} as a basic example, but let me go into detail -

There will be product IDs looking something like SRV-1234, RPT-GS32, QVC-RBT, etc - so my array variable with wildcard would look something like:

arrHardware = {“SRV*”, “RPT*”, “QVC*” }

Thank you again. I am guessing we would be using a different LINQ method in this case. Looking forward to your response.

lets pickup a basic regex approach for a first shot
grafik

arrPatterns = {“SRV-.+?\b”, “RPT-.+?\b”, “QVC-.+?\b”}

Assign Activity
arrMatches =

(From p in arrPatterns
Let ms = System.Text.RegularExpressions.Regex.Matches( CurrentRow.ByIndex(0).toString.ToUpper, p)
From m in ms.Cast(Of Match)
Select v=m.Value).toArray

So, now it is all about the patterns and its finetuning

Also Have a look here:
grafik

Feel free to share with us some more specific sample data

1 Like