If Regex Group is Empty skip it

Hello Friends!

I have a problem with Regex.

So i have a lot of documents with different keywords but the same result.

So now i am filtering every Document with each Keyword to find the Result.

But in some cases the a Keyword is found by Regex but isnt the right one for my Result.

is there any possibility to skip a Regexmatch if the Group is Empty?

Thank you alot!

Have a Look at the success property of the Match / groups(x). The returned boolean will returned If a Match was found or not


You can just filter match collection:

MatchCollection.Where(function(match) Not match.Groups(x).ToString.Equals(""))

Where x is the number of group which should not be empty


Can you share specific input and expected output? It’s no problem if dummy data.
We might be able to suggest better solution from it.