Advertisement
fbinnzhivko

7.00 To Uppercase

Jun 4th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. // Problem 5. Parse tags
  2.  
  3. /*  You are given a text. Write a program that changes the text in all regions surrounded by the tags <upcase> and </upcase> to upper-case.
  4.     The tags cannot be nested.
  5.  
  6. Example: We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.
  7.  
  8. The expected result: We are living in a YELLOW SUBMARINE. We don't have ANYTHING else.
  9.  */
  10.  
  11. using System;
  12. using System.Text.RegularExpressions;
  13.  
  14. class ParseTags
  15. {
  16.     static void Main()
  17.     {
  18.         string text = Console.ReadLine(); // please comment this line if usiing the line below
  19.                                           //string text = "We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.";
  20.  
  21.         // match and print
  22.         Console.WriteLine(Regex.Replace(text, "<upcase>(.*?)</upcase>", word => word.Groups[1].Value.ToUpper()));
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement