language: C# (mono-2.8)
date: 184 days 9 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
 
namespace SO13389560Balancing
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "~(a b (c) d (e f (g) h) i) j (k (l (m) n) p) q";
            string pattern = @"(?<=~[(](?:[^()]*|(?<Depth>[(])|(?<-Depth>[)]))*)[a-z]";
        
 
            s = Regex.Replace(s, pattern, "!");
 
            Console.WriteLine(s);
            //Console.ReadKey();
        }
    }
}