fork(2) download
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var text="red 1 green 3 blue";
  10. Console.WriteLine(string.Join(";", Regex.Split(text, @"red|green|blue")));
  11. Console.WriteLine(string.Join(";", Regex.Split(text, @"red|green|blue").Where(x => !string.IsNullOrEmpty(x))));
  12. }
  13. }
Success #stdin #stdout 0.08s 21788KB
stdin
Standard input is empty
stdout
; 1 ; 3 ;
 1 ; 3