How to add values in a list that contain keywords that do not have to be case-sensitive into another list?

Hi friends :smiley:

My process loops through a folder and checks excel files for a specific sheet name “GL Queries”. If one or many is found, it then loops through them to manipulate and filter rows.

I am currently using the Get Workbook Sheets activity within the current workbook scope and outputting a list variable named list_fileSheets. I have created another variable named list_fileSheetsFiltered. Both are type: System.Collections.Generic.List<System.String>.

I am then using an Assign activity and setting it as such: list_fileSheetsFiltered = list_fileSheets.Where(Function(b) b.Contains(“GL Queries”, StringComparer.CurrentCultureIgnoreCase)).ToList.

This assign produces the following error:

Complier error(s) encountered processing expression “list_fileSheets.Where(Function(b) b.Contains(“GL Queries”, StringComparer.CurrentCultureIgnoreCase)).ToList”. Option Strict On disallows implicit conversions from ‘String’ to ‘Char’. ‘System.StringComparer’ cannot be converted to ‘System.Collections.Generic.IEqualityComparer(Of Char)’ because ‘Char’ is not derived from ‘String’, as required for the ‘In’ generic parameter ‘T’ in ‘Interface IEqualityComparer(Of In T)’.

Multiple users are naming these sheets, so I would prefer the “filter” match with strings that are in any case.

Thanks!! :smiley:

Hi Emily,

Not a huge .Net developer so I can’t tell why it’s not working (other that reprint the error message). But maybe I can give you a couple of alternatives:

  1. Non fancy: list_fileSheets.Where(function(b) b.toUpper(“GL QUERIES”))

  2. fancy one: list_fileSheets.Where(function(b) Regex.isMatch(b, “GL Queries”,RegexOptions.IgnoreCase))

Let me know if it works

1 Like

Hi Martí, :smiley:

Thank you for the response! Option A could work if I set the current sheet ToUpper as well, otherwise it wouldn’t match. I’ll leave this as a backup plan in case I cannot do it all in one step!

As for option 2, I do not have a lot of experience with Regex. I tried inputting your solution, but I received this message:

Compiler error(s) encountered processing expression “list_fileSheets.Where(function(b) Regex.isMatch(b, “GL Queries”, RegexOptions.IgnoreCase))”. ‘Regex’ is not declared. It may be inaccessible due to its protection level. ‘RegexOptions’ is not declared. It may be inaccessible due to its protection level.

I definitely think this is the right direction! Any further troubleshooting is appreciated!! :smiley:

Add system.text.regularexpressions in the import tab (bottom of your screen)


OR use the code as system.text.regularexpressions.Regex.isMatch

Hope this resolves your issue.

1 Like

Hey emdev!

You can filter using LINQ! Look this example:

Note “list_strFiltered” is an empty List!



Lets print filtered list!

Heres the output!

Hope this helps!

1 Like


That did the trick! So simple! I’m still relatively new to UiPath and it did seem as if I was missing some sort of using statement. I wasn’t even aware of the import tab!

Thank you so much!!! Best wishes! :smiley:

Hi Gabriel,

Thank you so much for your time and response!! I greatly appreciate it!

This does the trick too! :smiley:


1 Like

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