I'm new in programming and need some help ;-)
how can I replace multiple patterns in a string?
Example:
static void Main(string[] args)
{
string input = "this is a test AAA one more test adakljd jaklsdj BBB sakldjasdkj CCC";
string [] pattern = {"AAA", "BBB","CCC"};
string replacement = "XXX";
string result = null;
for (int i = 0; i < pattern.Length; i++)
{
result = Regex.Replace(input, pattern[i], replacement);
}
Console.WriteLine(result);
}
Want the result:
this is a test XXX one more test adakljd jaklsdj XXX sakldjasdkj XXX
But I get:
this is a test AAA one more test adakljd jaklsdj BBB sakldjasdkj XXX
thx for help in advance!