Advertisement
dkeray

UpperCase in Tags

Jan 27th, 2013
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static string UpperCaseInTags(string text, string tag)
  6.     {
  7.         int count = 0;
  8.  
  9.         string TagStart = "<" + tag + ">";
  10.         string TagEnd = "</" + tag + ">";
  11.         while (text.IndexOf(TagStart) != -1)
  12.         {
  13.             int PosStart = text.IndexOf(TagStart);
  14.             int PosEnd = text.IndexOf(TagEnd);
  15.             string temp = text.Substring(PosStart + TagStart.Length, PosEnd - PosStart - TagStart.Length);
  16.             text = text.Replace(TagStart + temp + TagEnd, temp.ToUpper());
  17.         }
  18.         return text;
  19.     }
  20.  
  21.     static void Main()
  22.     {
  23.         string text = "We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.";
  24.         string tag = "upcase";
  25.         Console.WriteLine(UpperCaseInTags(text, tag));
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement