Advertisement
ivandrofly

Capture and Store tags

Feb 11th, 2025
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1.             string s = "";
  2.             int l = 0;
  3.             var sb = new StringBuilder();
  4.             for (int r = 0; r < s.Length + 1; r++)
  5.             {
  6.                 if (r < s.Length)
  7.                 {
  8.                     if (s[r] == '<')
  9.                     {
  10.                         l = 0;
  11.                     }
  12.                     else if (s[l] == '<' && s[r] == '>')
  13.                     {
  14.                         string tag = s.Substring(l, r - l + 1);
  15.  
  16.                         if (!IsKnownTag(tag))
  17.                         {
  18.                             sb.Append(tag);
  19.                         }
  20.  
  21.                         l = r + 1;
  22.                     }
  23.                     else if (s[l] != '<')
  24.                     {
  25.                         sb.Append(s[r]);
  26.                     }
  27.                 }
  28.                 else if (s[l] == '<')
  29.                 {
  30.                     sb.Append(s.Substring(l, r - l));
  31.                 }
  32.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement