ellapt

T14.5.TurnUpperCase

Feb 3rd, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class TurnUpperCase
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Change text in all regions surrounded by <upcase> and </upcase> to uppercase.");
  9. Console.WriteLine("The tags cannot be nested\n");
  10.  
  11. /* Sample text: We are living in a <upcase>yellow submarine</upcase>.
  12. We don't have <upcase>anything</upcase> else. */
  13.  
  14. Console.Write("Enter the text: ");
  15. string text = Console.ReadLine();
  16. text = Regex.Replace(text, "(<upcase>)(.*?)(</upcase>)", m => m.Groups[2].Value.ToUpper());
  17. Console.WriteLine(text);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment