fork(2) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string sentence = "Hello World <Red>This is some red text </Red> This is normal <Blue>This is blue text </Blue>";
  9. string[] matchSegments = Regex.Split(sentence,@"(<\w+>)(.*?)<\/\w+>");
  10. foreach (string value in matchSegments)
  11. {
  12. if(value.Contains("<") && value.Contains(">"))
  13. Console.Write(value);
  14. else
  15. Console.WriteLine(value);
  16. }
  17. }
  18. }
Success #stdin #stdout 0.02s 30424KB
stdin
Standard input is empty
stdout
Hello World 
<Red>This is some red text 
 This is normal 
<Blue>This is blue text