fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var path = "qwerty-qwerty-some-random-string";
  9. var root = "aardvark-junk-qwerty-qwerty";
  10.  
  11. var prefix = root.Select((ch, i) => root.Substring(i))
  12. .Where(pref => path.StartsWith(pref))
  13. .DefaultIfEmpty("")
  14. .First();
  15. var result = path.Substring(prefix.Length);
  16.  
  17. Console.WriteLine(result);
  18. }
  19. }
Success #stdin #stdout 0.05s 37144KB
stdin
Standard input is empty
stdout
-some-random-string