Advertisement
Guest User

Change_to_Uppercase

a guest
Aug 8th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _6.Change_to_Uppercase
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string text = Console.ReadLine().Trim();
  14. int upcaseStart = text.IndexOf("<upcase>");
  15. int upcaseFinish = text.IndexOf("</upcase>");
  16. string replacement = text.Substring(upcaseStart + 8, upcaseFinish - upcaseStart - 8);
  17. replacement = replacement.ToUpper();
  18. string toDelete = text.Substring(upcaseStart, upcaseFinish + 8 + 1 - upcaseStart);
  19.  
  20. while (text.Contains("<upcase>"))
  21. {
  22. text = text.Replace(toDelete, replacement);
  23. upcaseStart = text.IndexOf("<upcase>");
  24. upcaseFinish = text.IndexOf("</upcase>");
  25. if (upcaseStart != -1 && upcaseFinish != -1)
  26. {
  27. replacement = text.Substring(upcaseStart + 8, upcaseFinish - upcaseStart - 8);
  28. replacement = replacement.ToUpper();
  29. toDelete = text.Substring(upcaseStart, upcaseFinish + 8 + 1 - upcaseStart);
  30. }
  31.  
  32. }
  33.  
  34. Console.WriteLine(text);
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement