using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var inLine = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Common\", \"Libraries\\Common\\Common.csproj\", \"{91197577-34B9-4D46-B3FE-A8589D4380B1}\""; var regex = new Regex(@"(Project\(""{[\w-]*}""\) = "")(?[^\s""]*)("", "")(?[^\s""]*)("", ""{[\w-]*}"")"); var projectName = string.Empty; var relativePath = string.Empty; var replaced = regex.Replace(inLine, m => { projectName = m.Groups["ProjectName"].Value; relativePath = m.Groups["relativePath"].Value; return $"{m.Groups[1].Value}{m.Groups[2].Value}{m.Groups[3].Value}"; }); Console.WriteLine("Project Name: {0}\nRelative Path: {1}\nReplaced: {2}", projectName, relativePath, replaced); } }