DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Aniruddha has posted 40 posts at DZone. View Full User Profile

C# Regex Replace

  • submit to reddit
        For replacing matches with different strings. The method 'MethodName' will have Match object as the only paramater. 'MethodName' will be executed for every match in fileContent.

string replacement = Regex.Replace(fileContent, @"pattern", new MatchEvaluator(MethodName));