Regex to test if strings exist in a string to match

For example my keyword string is Address Number Description and I have a string to match which is
Address22 Number232 Description232 or Address’ss Numbers Descriptions or other combination.

Since Address Number Description is present the the ff.examples which is Address22 Number232 Description232 or Address’ss Numbers Descriptions contains the ff. strings Address Number Description it should return true.

But if for example the string to match is Addriss’ss Numburs Descriptionsss it should return false cause the strings are no longer present and its a wrong spelling already. Any idea thanks .

And it should be dynamic I just used Address Number Description as example. Thank you.

Idea would be appreciated guys . Thanks

Input : Address Number Description
StringToMatch : Addresssss Numberrrr Descriptionssss
output : true

Input : Address Number Description
StringToMatch : 3Addressss232s 3Numberrr343r 23Descriptionssss
output : true

Input : Address Number Description
StringToMatch : 3Addrissss232s 3Numborrr343r 23Descripteonssss
output : false

Hello

I am still a bit confused with this one.

Can you please tell us about the pattern of the text?

Regex might not be the best solution? You might just need to use a “IsMatch” activity…

Feel free to check out my Regex MegaPost:

1 Like

Based on the input and when you compare it to Addresssss Numberrrr Descriptionssss , all the string exist which is Address Number Description

Input : Address Number Description
StringToMatch : Addresssss Numberrrr Descriptionssss
output : true

The pattern could be check based on the input above and examples Sir.

The regular expression below will match the first two StringToMatch but not the third one. You can use it with IsMatch activity.

Address.+Number.+Description

what if we wanted to make it dynamic ?

I’m not sure if I understand you correctly but if you want to create the regular expression on the fly, just replace the spaces with “.+”.

InputString = "Address Number Description"
MyRegularExpression = InputString.Replace(" ", ".+")

Another examples

Input : Hello World
StringToMatch : asdasdHellodasdas World4334
output : true

Input : Hello World
StringToMatch : Hillo343 Wirld4334
output : false

Ok, then a string replace will solve it as I mentioned in my previous post.

MyRegularExpression = Input.Replace(" ", ".+")
Output = System.Text.RegularExpressions.IsMatch(StringToMatch, MyRegularExpression)
1 Like

Thanks for the idea guys

1 Like

@ptrobot one last question sir , for example I loop through a range range (excel) how do I show every column in a loop inside a for each row ?

for example I want to print each column inside the for each row

Use a For Each activity inside your For Each Row activity to loop through all columns. The TypeArgument for the For Each activity should be System.Data.DataColumn. Then you can access cell values for each column using row(col).


image

1 Like

@ptrobot

Is there a way @ksrinu070184 that I will only check the first row column? and not everything ?!

for example I only wanted to check the first row column which are Order date , region , items unit , unit costs and total and dont include the other columns

dddd

Just remove the For Each Row activity and keep the For Each loop. If you have the option Add Headers checked in the Read Range activity, you can get the header name with col.ColumnName. If that option is unchecked you can read the first row using Dynamic_DT.Rows(0)(col).ToString

image

1 Like

Hi sir , is it possible to loop through the first row columns ? like looping Dynamic_DT.Rows(0)(col) ?
so i will only check the ff.

Yes, if you uncheck the option Add Headers in the Read Range activity you can read the first row with Dynamic_DT.Rows(0)(col). If not Dynamic_DT.Rows(0) will point to the second row on in your Excel sheet.

image

My goal is only to loop on the column headers nothing else …

so if Ioop through this the output should be OrderDate , Region , Rep , Item, Units , Unit Cost , Total and should ignore the rest

dddd