Depending on what you are trying to do ...
List<Boolean> rslt; String searchIn; Regex regxObj; MatchCollection mtchObj; Int32 mtchGrp; searchIn = @"[(34) Some Text - Some Other Text] [(1)]"; regxObj = new Regex(@"\[\(([^\)]+)\)[^\]]*\]"); mtchObj = regxObj.Matches(searchIn); if (mtchObj.Count > 0) rslt = new List<bool>(mtchObj.Count); else rslt = new List<bool>(); foreach (Match crntMtch in mtchObj) { if (Int32.TryParse(crntMtch.Value, out mtchGrp)) { rslt.Add(true); } }
Tim
source share