fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var inLine = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Common\", \"Libraries\\Common\\Common.csproj\", \"{91197577-34B9-4D46-B3FE-A8589D4380B1}\"";
  12. var regex = new Regex(@"(Project\(""{[\w-]*}""\) = "")(?<projectName>[^\s""]*)("", "")(?<relativePath>[^\s""]*)("", ""{[\w-]*}"")");
  13. var projectName = string.Empty;
  14. var relativePath = string.Empty;
  15. var replaced = regex.Replace(inLine, m => {
  16. projectName = m.Groups["ProjectName"].Value;
  17. relativePath = m.Groups["relativePath"].Value;
  18. return $"{m.Groups[1].Value}{m.Groups[2].Value}{m.Groups[3].Value}";
  19. });
  20. Console.WriteLine("Project Name: {0}\nRelative Path: {1}\nReplaced: {2}", projectName, relativePath, replaced);
  21. }
  22. }
Success #stdin #stdout 0.06s 21388KB
stdin
Standard input is empty
stdout
Project Name: 
Relative Path: Libraries\Common\Common.csproj
Replaced: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "", "", "{91197577-34B9-4D46-B3FE-A8589D4380B1}"