List.IndexOf case insensitive, trim whitespace

Hi, I am currently using the method list.IndexOf(“string”) to find the index of an item with a certain value. How do I modify this so that it matches even if the string is case insensitive and contains whitespace? E.g. “String”, “sTring”, " stRing" etc


is this what you are looking for?

getIndexOfString.xaml (5.9 KB)


Sorry, what I am looking for is that I have a List of String, and I want to find the index of a certain string value within that list. It should return the index regardless of whether the List item has different case or has whitespace.


Lets say you have list called l1

String.join(" ",l1.toarray) and use this in above solution.

Do you have a solution which uses Lambda expressions or LINQ? Thanks

Preferably need to assign the boolean within one activity


At your service sir.:slight_smile:

l1.FindIndex(Function(x) x.Equals(“yourStringHere”, StringComparison.OrdinalIgnoreCase))

Hi, does this work even with whitespace?

Give this a try


Doesn’t work… it keeps returning -1

The full expression is dataRow.ItemArray.ToList.FindIndex(Function(x)…)

When I use dataRow.ItemArray.ToList.IndexOf it works but when I use the Lambda expression it does not…

I am using the same find string in FindIndex(Function(x) x.Equals(“Field”, …)) as I am using in IndexOf(“Field”)

@rahatadi What could be causing it not to work?


Is it datarow?
L1.findIndex(function(x) x(“fieldname”).equals(“yourStringHere”, StringComparison.OrdinalIgnoreCase))
Could you please post simplified version of your code?


Hi, it is a DataRow but it does not have column names so I have to convert it to List first before using FindIndex and find by value… x(“fieldname”) cannot be used in this case


could you please upload simplified version of your workflow?

@rahatadi Hi, i need to pick all the string in array irresepective of case. I have a string name in samll case in config. But when i pick in array of string, i should pick even if it uppercase or mixed case.So how to use the ordinal ignore case here??