fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var pattern = @"/(?<Command>\w+)(?:@(?<Target>\S+))?(?<Args>(?s).*)";
  11. var text = "/ping@mybot arg1 arg2";
  12. var match = Regex.Match(text, pattern);
  13. if (match.Success)
  14. {
  15. Console.WriteLine(match.Groups["Command"].Value);
  16. Console.WriteLine(match.Groups["Target"].Value);
  17. Console.WriteLine(match.Groups["Args"].Value);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.08s 21752KB
stdin
Standard input is empty
stdout
ping
mybot
 arg1 arg2