language: C# (mono-2.8)
date: 285 days 4 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System;
using System.Text.RegularExpressions;
 
public class Test
{
        public static void Main()
        {
                string input = "a+aa-b";
                string variable = "a";
                string replacement = "1";
                Regex regex = new Regex(@"\b" + variable + @"\b");
                string result = regex.Replace(input, replacement);
                Console.WriteLine(result);
        }
}