locked
How to see if any date text with in a list of string text RRS feed

  • Question

  • User-1188570427 posted

    What would be a LINQ statement that could check to see if a list of date text is found in another list of random text?

    Example:

    List of strings (date text format) -DateTextList

    "Thu, Mar 28"

    "Fri, Mar 29"

    "Sat, Mar 30"

    ---------------------------------

    List of Strings - RecordTextList

    "Thu, Mar 28vs Pittsburgh W5-3 1-0Duke 1-0Taillon 0-1Hernandez 144,049"

    "Sun, Mar 31vs Pittsburgh 1:10 PM Roark Musgrove Tickets as low as $14"

    "Tue, Mar 26vs Pittsburgh 1:10 PM Roark Musgrove Tickets as low as $14"

    So if any of the DateTextList records is contained in the list of records of RecordTextList, I want to return TRUE.

    Friday, March 29, 2019 1:18 AM

Answers

  • User-1188570427 posted

    What would be a LINQ statement that could check to see if a list of date text is found in another list of random text?

    Example:

    List of strings (date text format) -DateTextList

    "Thu, Mar 28"

    "Fri, Mar 29"

    "Sat, Mar 30"

    ---------------------------------

    List of Strings - RecordTextList

    "Thu, Mar 28vs Pittsburgh W5-3 1-0Duke 1-0Taillon 0-1Hernandez 144,049"

    "Sun, Mar 31vs Pittsburgh 1:10 PM Roark Musgrove Tickets as low as $14"

    "Tue, Mar 26vs Pittsburgh 1:10 PM Roark Musgrove Tickets as low as $14"

    So if any of the DateTextList records is contained in the list of records of RecordTextList, I want to return TRUE.

    This appears to be what I need:

                    var listToCheckAgainstDateList = getMainData.Select(s => s.InnerText).ToList();
                    var match = listToCheckAgainstDateList.Where(w => dateList.Any(a => w.Contains(a))).Any();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 29, 2019 2:54 AM