, , Regex, ( , ) .
, , . .
, MatchCollection , , 3- - , - , !
StringBuilder builder = new StringBuilder();
builder.AppendLine("djdodjodo\t\t3893983");
builder.AppendLine("dddfddffd\t\t233");
builder.AppendLine("djdodjodo\t\t39838");
builder.AppendLine("djdodjodo\t\t12");
builder.AppendLine("djdodjodo\t\t444");
builder.AppendLine("djdodjodo\t\t5683");
builder.Append("djdodjodo\t\t33");
string text = builder.ToString();
MatchCollection matches = Regex.Matches(text, @"([^\s^\t]+)(?:[\s\t])+([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
IDictionary<int, string> lines = matches.Cast<Match>()
.ToDictionary(match => int.Parse(match.Groups[2].Value), match => match.Groups[1].Value);
string value = lines[33];
:
, - , , , , , "[-]. [-]" ( : address.Name).
([\w\.]+)[\s\t]+([0-9]+), .
!;)
2:
, , ([^\s^\t]+)(?:[\s\t])+([0-9]+).
, - , .
3:
, .NET 3.0 ToDictionary .NET 3.5. .NET 3.0, ToDictionary(...) :
Dictionary<int, string> lines = new Dictionary<int, string>();
foreach(Match match in matches)
{
lines.Add(int.Parse(match.Groups[2].Value), match.Groups[1].Value);
}