using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<topro>\([^)]*?\bpro +)(?<afterpro>.*?\))|(?<withoutpro>\(.*?\))";
string substitution = @"${topro}\U${afterpro}\L${withoutpro}\E";
string input = @"4377631753733131 (pro alber con tr33)
886uhghsdfdsfh (pro cios tui tr32)
rtyqrey 6y46457 6372576 (Flrt ghnap tsr)
537657QQRFytyvg (flipzz Reyhdf frfg33)
4377631753733131 (pro alber con tr33) (flipzz Reyhdf frfg33) (foo pro bar pro cios tui tr32)
I would like all words after ""pro"" to be capitalized. If ""pro"" is not present, all words in the brackets must be lowercase, for have :
4377631753733131 (pro Alber Con Tr33)
886uhghsdfdsfh (pro Cios Tui Tr32)
rtyqrey 6y46457 6372576 (flrt ghnap tsr)
537657QQRFytyvg (flipzz reyhdf frfg33)";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx