fork download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var str = "Option (A) and option ( B ) and (c )";
  10. var matches = Regex.Matches(str, @"\([^()]*\)");
  11. foreach (Match match in matches) {
  12. Console.WriteLine("Value: {0}", match.Value);
  13. Console.WriteLine("Position: {0}",match.Index);
  14. Console.WriteLine("Length: {0}",match.Length);
  15. }
  16. }
  17. }
Success #stdin #stdout 0.03s 134720KB
stdin
Standard input is empty
stdout
Value: (A)
Position: 7
Length: 3
Value: (   B   )
Position: 22
Length: 9
Value: (c     )
Position: 36
Length: 8