Little bit about regular expressions.

First one my small example:

using System;
using System.Text.RegularExpressions;

namespace RegularExpressions
{
  class Program
  {
    static void Main(string[] args)
    {
      string pattern = "([a])";
      string myName = "Stanko Milosev";
      Console.WriteLine(Regex.IsMatch(myName, pattern));
      Console.ReadKey();
    }
  }
}

According to Regular Expression Language - Quick Reference, pattern [a] means:

[character_group] Matches any single character in character_group. By default, the match is case-sensitive.

Another example comes from codewars. Task was:

Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.

Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Polycarpus inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.

For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".

Recently, Jonny has heard Polycarpus's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Polycarpus remixed. Help Jonny restore the original song.

Solution:

return Regex.Replace(input, "(WUB)+", " " ).Trim();

Where plus sign means:

Matches the previous element one or more times.

And one more my, from my point of view, easier, example:

    static void Main(string[] args)
    {
      string pattern = "(ta)+";
      string myName = "tata";
      Console.WriteLine(Regex.Replace(myName, pattern, "ma"));
      Console.ReadKey();
    }

Result is "ma" - multiple "ta" is replaced with one ma