fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var list = new List<string>() {"The quick brown [fox] jumps over the lazy dog]",
  10. "The quick brown [fox] jumps over the lazy [dog]",
  11. "The quick brown [fox jumps over the lazy [dog]"};
  12. list.ForEach(m => Console.WriteLine("\nMatch: " + Regex.Match(m, @"\[([^][]*)]").Value +
  13. "\nGroup 1: " + Regex.Match(m, @"\[([^][]*)]").Groups[1].Value));
  14. }
  15. }
Success #stdin #stdout 0.11s 24728KB
stdin
Standard input is empty
stdout
Match: [fox]
Group 1: fox

Match: [fox]
Group 1: fox

Match: [dog]
Group 1: dog