Sumit Chourasia Sumit Chourasia - 1 year ago 54
C# Question

How to get dynamic word from particular pattern using Regex in C#

I'm trying to parse my .cs class which is having module aggregator. I want to get the Name of all the concrete class which i'm passing in those module handlers.
so I want to get the Name "ConfigurationContextBuilder" from the following line.


I tried following regex code but i'm not getting desired word.


Answer Source

., (, and ) are used in regex patterns, so you need to escape them using a backslash to make them match literally.

So the following regular expression will fix your problem: