using System; using System.Text.RegularExpressions; namespace RegExApplication { public class Program { public static void Main(string[] args) { string input = "atext[d][][ef]\nother[aa][][a]\nxxxxx[][xx][x][][xx]\nyyyyy[]"; string pattern = "(?m).*(\\[.*\\])"; Regex rgx = new Regex(pattern); Match match = rgx.Match(input); while (match.Success) { Console.WriteLine(match.Groups[1].Value); match = match.NextMatch(); } } } }