Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- class ChangeTextBetweenTagsWithUppercase
- {
- static void Main()
- {
- string str = "We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.";
- Console.WriteLine("Insert string with tags <upcase>...</upcase>");
- //string str = Console.ReadLine();
- Regex regex = new Regex (@"(<\s*upcase\s*>)(?<tag>.*?)(<\s*/upcase\s*>)");
- MatchCollection matches = regex.Matches(str);
- foreach (Match match in matches)
- {
- str = regex.Replace(str, match.Groups["tag"].Value.ToUpper(),1);
- }
- Console.WriteLine(str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement