Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _6.Change_to_Uppercase
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine().Trim();
- int upcaseStart = text.IndexOf("<upcase>");
- int upcaseFinish = text.IndexOf("</upcase>");
- string replacement = text.Substring(upcaseStart + 8, upcaseFinish - upcaseStart - 8);
- replacement = replacement.ToUpper();
- string toDelete = text.Substring(upcaseStart, upcaseFinish + 8 + 1 - upcaseStart);
- while (text.Contains("<upcase>"))
- {
- text = text.Replace(toDelete, replacement);
- upcaseStart = text.IndexOf("<upcase>");
- upcaseFinish = text.IndexOf("</upcase>");
- if (upcaseStart != -1 && upcaseFinish != -1)
- {
- replacement = text.Substring(upcaseStart + 8, upcaseFinish - upcaseStart - 8);
- replacement = replacement.ToUpper();
- toDelete = text.Substring(upcaseStart, upcaseFinish + 8 + 1 - upcaseStart);
- }
- }
- Console.WriteLine(text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement