Hashtable Global_Hash = new Hashtable(); List eta = new List(); List xcv = new List(); Regex RegexVar = new Regex(@"var\s+(\w+)\s*=+\s*([^;]+)\s*;"); //var name = ?; MatchCollection MatchesVar = RegexVar.Matches(rtb_JS.Text); foreach (Match MatchVar in MatchesVar) { if (MatchVar.Success) { var globalVAR = MatchVar.Groups[0].Value.ToString(); var VAR = MatchVar.Groups[1].Value.ToString(); var Value = MatchVar.Groups[2].Value.ToString(); var VarIndex = MatchVar.Index; var Indexvar = MatchVar.Groups[0].Index; eta.Add(globalVAR); xcv.Add(Indexvar); if (!Global_Hash.Contains(VarIndex)) { foreach (var wat in xcv) { foreach (var taw in eta) { if(Global_Hash.ContainsKey(wat)) {} else Global_Hash.Add(wat, taw); } } }