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.Text.RegularExpressions;
- namespace LettersToUpper
- {
- class LettersToUpper
- {
- static string ToUpper(string text)
- {
- string pattern = @"(?'OpenTag'<upcase>)(?'TagContent'.*?)(?'CloseTag'</upcase>)";
- StringBuilder resultString = new StringBuilder(text.Length, text.Length);
- int LastIndex = 0;
- Regex regex = new Regex(pattern);
- Match match = regex.Match(text);
- while (match.Success)
- {
- string patch = text.Substring(LastIndex, match.Index - LastIndex);
- string upperCasePatch = match.Groups["TagContent"].ToString();
- resultString.Append(patch);
- resultString.Append(upperCasePatch.ToUpper());
- LastIndex = match.Index + match.Length;
- match = match.NextMatch();
- }
- resultString.Append(text.Substring(LastIndex));
- return resultString.ToString();
- }
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement