Alternative for Contains Keyword

Hi,
I have one excel that I’m going to upload it into orchestrator queue:

Then I wanted to check in the column “place” if it has a value “pune” or not.

We can do this with Contains keyword but is there any alternative way to do this?

Thanks in advance

Hi @Nisha_K21

Can you try this

FinalDT = InputDT.AsEnumerable().Where(Function(row) row("Place").ToString.Split(","c).Any(Function(place) place.Trim().Equals("pune", StringComparison.OrdinalIgnoreCase))).CopyToDataTable

Regards,

@lrtetala ,
Suppose if these data is placed in orchestrator queue, How can I validate that?

@Nisha_K21

isPunePresent = in_TransactionItem.SpecificContent(“Place”).ToString.Split(","c).Any(Function(place) place.Trim().Equals(“pune”, StringComparison.OrdinalIgnoreCase))

If isPunePresent
’ Pune is present
Else
’ Pune is not present
End If

Regards,

@lrtetala Thanks for the response

Is it possible to do that without using LINQ?

Hi @Nisha_K21

You can try this way without Linq,

in_TransactionItem.SpecificContent("place").ToString.Trim.ToUpper.Contains("PUNE")

image

Regards,
Gowtham K

@Gowtham_K115 ,

I tried this method it worked but I wanted to check with alternative of contains keyword.

Do we have alternative method for this?

@Nisha_K21

Array_Place = in_TransactionItem.SpecificContent(“Place”).ToString.Split(","c)

For Each place In Array_Place 
    If place.Trim().Equals("pune", StringComparison.OrdinalIgnoreCase) Then
        Pune is Present
    Else
        Pune is Not Present
    End If

Regards,

@Nisha_K21

You can try this,

System.Text.RegularExpressions.Regex.IsMatch(in_TransactionItem.SpecificContent("place").ToString.Trim.ToUpper, "\bPUNE\b")

Regards
Gowtham K

You can use IndexOf method and check if is result is >= 0. Why don’t you like Contains though? It’s the best for this case.