Try using
Regex
's
Replace()
:
using System;
using System.Text.RegularExpressions;
namespace ConsoleApplication16
{
class Program
{
static readonly Regex Pattern = new Regex("A0[2-5]|A1[0-5]", RegexOptions.Compiled);
static void Main(string[] args)
{
string input = "BDC, ASD, DFS, A02, A04, A13, QAS,ZXA";
string replacement = "ABC";
Console.WriteLine(input);
string output = Pattern.Replace(input, replacement);
Console.WriteLine(output);
Console.ReadLine();
}
}
}
Gives:
BDC, ASD, DFS, A02, A04, A13, QAS,ZXA
BDC, ASD, DFS, ABC, ABC, ABC, QAS,ZXA