I have a long string and within that string I have the following text:
\"formatter\": \"SomeInformationHere\"
I need to fi
Everybody else has pretty much nailed it with using capturing groups and substitutions, just wanted to provide a little more context:
The main two things that are used here are Named Capturing Groups and Substitutions
static void Main(string[] args) {
var input = new[] {
"\"formatter\": \"John\"",
"\"formatter\": \"Sue\"",
"\"formatter\": \"Greg\""
};
foreach (var s in input) {
System.Console.Write("Original: [{0}]{1}", s, Environment.NewLine);
System.Console.Write("Replaced: [{0}]{1}", ReFormat(s), Environment.NewLine);
System.Console.WriteLine();
}
System.Console.ReadKey();
}
private static String ReFormat(String str) {
//Use named capturing groups to make life easier
var pattern = "(?