fork(1) download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var text = "<p>AI.For example <p>A.I<p>BB.";
  11. var result = new List<string>();
  12. var rx = new Regex(@"(?=<p>\s*([A-Z])\1*\.)");
  13. var idx = 0;
  14. foreach (Match m in rx.Matches(text)) {
  15. result.Add(text.Substring(idx, m.Index-idx));
  16. idx = m.Index;
  17. }
  18. if (idx < text.Length - 1) {
  19. result.Add(text.Substring(idx));
  20. }
  21. Console.WriteLine(string.Join("\n", result));
  22. }
  23. }
Success #stdin #stdout 0.06s 21252KB
stdin
Standard input is empty
stdout
<p>AI.For example 
<p>A.I
<p>BB.