fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"cn=(?!.*cn=)([^\\]+)";
  9. string input = @"ou=company\ou=country\ou=site\cn=office\cn=name\ou=pet";
  10.  
  11. foreach (Match m in Regex.Matches(input, pattern)) {
  12. Console.WriteLine("{0}, {1}", m.Value, m.Groups[1].Value);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.04s 134720KB
stdin
Standard input is empty
stdout
cn=name, name