Convert regex matches to the list of strings

Convert regex matches to the list of strings

I'm trying to find equal sub-string in big list about 50 000 strings, this way fine:

I'm trying to find equal sub-string in big list about 50 000 strings, this way fine:

var results = myList.FindAll(delegate (string s) { return s.Contains(myString); });

but it also looks for sub-string with part of word, for example, if I'm looking for "you do" it founds also extra "you dont" because contains "you do..".

So, this answer to my previous question supposedly should work as i need, but I'm not sure, how to get strings list from regex matches for particular code:

foreach (string phrase in matchWordsList)
{
     foreach (string str in bigList)
     {
          string[] stringsToTest = new[] { phrase };
          var escapedStrings = stringsToTest.Select(s => Regex.Escape(s)); 
          var regex = new Regex("\\b(" + string.Join("|", escapedStrings) + ")\\b");
          var matches = regex.Matches(str);

 foreach (string result in matches) /// Incorrect: System.InvalidCastException 
 {
     resultsList.Add(result);
 }

}

Getting strings from matches directly to the list throws exception:

An unhandled exception of type 'System.InvalidCastException' occurred in test.exe
Additional information: Unable to cast object of type 'System.Text.RegularExpressions.Match' to type 'System.String'.

So, I'm trying to figure out, hot to convert var matches = regex.Matches(str); to the list

c-sharp regex linq

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Is Using LINQ in C# Bad for Performance?

LINQ (Language INtegrated Query) is a set of features in C# for concise and declarative code. I use it pretty much wherever I can, but sometimes I wonder and people ask: is this a performance trap? It would be painful to have to replace many usages of LINQ with other constructs in addition to time spent finding that to be an actual bottleneck. Let’s do a basic benchmark to see what using LINQ might cost us compared to more traditional constructs such as for and foreach loops, and see if this worry is valid.

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look