Compare two lists from user

how to compare two lists in python
compare two lists java
python compare two lists of strings
python compare two lists element wise
python compare two lists equal
how to compare two lists in python and return non matches
python compare list elements
python check if two lists have same elements

I have a predefined list List words.Say it has 7 elements:

List<string> resourceList={"xyz","dfgabr","asxy", "abec","def","geh","mnbj"}

Say, the user gives an input "xy+ ab" i.e he wants to search for "xy" or "ab"

string searchword="xy+ ab";

Then I have to find all the words in the predefined list which have "xy" or "ab" i.e all words split by '+'

So, the output will have:


I am trying something like:

resourceList.Where(s => s.Name.ToLower().Contains(searchWords.Any().ToString().ToLower())).ToList()

But, I am unable to frame the LINQ query as there are 2 arrays and one approach I saw was concatenate 2 arrays and then try; but since my second array only contains part of the first array, my LINQ does not work.

You need to first split your search pattern with + sign and then you can easily find out which are those item in list that contains your search pattern,

var result = resourceList.Where(x => searchword.Split('+').Any(y => x.Contains(y.Trim()))).ToList();


Your resourceList is

List<string> resourceList = new List<string> { "xyz", "dfgabr", "asxy", "abec", "def", "geh", "mnbj" };

And search pattern is,

string searchword = "xy+ ab";    

Output: (From Debugger)

How can I compare two lists in python and return matches, Use set.intersection(), it's fast and readable. > another a bit more functional way to check list equality for list 1 (lst1) and list 2 (lst2) where objects have depth one� Step 1: To highlight non-matching cells row by row, select the entire data first. Step 2: Now press the excel shortcut key “ F5 ” to open the “Go to Special” tool. Step 3: Press F5 key to open this window. Now in the “Go-To” window press “Special” tab. Step 4: In the next window “Go To Special”

Try following which doesn't need Regex :

            List<string> resourceList= new List<string>() {"xyz","dfgabr","asxy","abec","def","geh","mnbj"};
            List<string> searchPattern = new List<string>() {"xy","ab"};

            List<string> results = resourceList.Where(r => searchPattern.Any(s => r.Contains(s))).ToList();

How to Compare Two Lists in Python, This example describes how to compare two lists in Excel using conditional formatting. Select 'Use a formula to determine which cells to format'. 6. Enter the� We use various ways to compare two cells using functions in Excel. Some of these ways are: Comparing two columns row-by-row. Comparing many columns for row matches or differences. Highlight matches or differences between two columns. Highlight row matches and differences. Compare two lists and pull matching data.

You can try querying with a help of Linq:

List<string> resourceList = new List<string> {
  "xyz", "dfgabr", "asxy", "abec", "def", "geh", "mnbj"

string input = "xy+ ab";

string[] toFind = input
  .Select(item => item.Trim()) // we are looking for "ab", not for " ab"

// {"xyz", "dfgabr", "asxy", "abec"}
string[] result = resourceList
  .Where(item => toFind
     .Any(find => item.IndexOf(find) >= 0))
// Let's have a look at the array
Console.Write(string.Join(", ", result));


xyz, dfgabr, asxy, abec

If you want to ignore case, add StringComparison.OrdinalIgnoreCase parameter to IndexOf

string[] result = resourceList
  .Where(item => toFind
     .Any(find => item.IndexOf(find, StringComparison.OrdinalIgnoreCase) >= 0))

Compare Two Lists in Excel, Using sum() + zip() , we can get sum of one of the list as summation of 1 if both the index in two lists have equal elements, and then compare� Thanks for the replies. What I'm really looking for is a way to compare two lists to find mismatches. In any other language, I'd loop through one array, and for each item, check if it exists in the second array. Your suggestion loops through a list, and for each item, does a 'Get Records'.

Python, It accepts data as item lists or as a table with the input data in columns. It displays graphical and Clear All. Load example lists. Case-sensitive comparison. Vlookup to compare two lists in separated worksheets If you have Kutools for Excel, with its Select Same & Different Cells feature, you can find and highlight the same or different values from two separate worksheets as quickly as you can. Click to download Kutools for Excel!

MULTIPLE LIST COMPARATOR, Compare list differences online with this text fixer and list comparison tool. A & B, then click Compare Lists to work out the differences between the two lists are many use-cases for the tool from Finance, Engineering and Computing to any � Compare Two Lists Via One Property Using LINQ. Ask Question Asked 7 years, 1 month ago. Active 1 year, 4 months ago. Viewed 85k times 44. 13. Say I have the following

ListDiff, In this tutorial you will learn how to compare two list with the help of these two sets by using difference() function and use the if() condition to� A frequent task in business is to compare two lists of data. Have a master customer, product, mailing list etc and need to compare it to another list to see what is missing and needs to be added?

  • I edited your question and added the new information. Please remember to always include all the relevant information into the question itself.
  • your variable "searchword" will it be regex?
  • Is the space after the + in searchword (shouldn't that be searchwords?) to be ignored? Why doesn't the output have asxy? Why does the output have an empty string?
  • Thanks all for your valuable comments and solutions