fork(4) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class RegEx
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"(?<=cn=)[\w\s]+(?=\\ou.*?$)";
  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. {
  13. Console.WriteLine("{0}", m.Value);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.03s 133888KB
stdin
Standard input is empty
stdout
name