fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] inp = new string[] {
  9. "Some words",
  10. "Some words and some other words",
  11. "Some words, more words and some other words",
  12. "Some words, more words, and some other words"
  13. };
  14. foreach (string s in inp) {
  15. string[] phrases = (Regex.Split(s, @"(?:,\s*|\s+)and\s+|,\s*"));
  16. Console.WriteLine(string.Join("\n", phrases));
  17. }
  18. }
  19. }
Success #stdin #stdout 0.08s 25508KB
stdin
Standard input is empty
stdout
Some words
Some words
some other words
Some words
more words
some other words
Some words
more words
some other words