using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var strs = new List { " [ f ] s = t", "s = t"}; var pattern = @"(?:^\p{Zs}*|])([^]=]*)="; foreach (var s in strs) { var match = Regex.Match(s, pattern); if (match.Success) Console.WriteLine(match.Groups[1].Value); } } }