using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace regular_expressions
{
class Program
{
static void Main(string[] args)
{
string string1 = "04:03:27 Jesse 192.168.0.2 Liberty";
Regex theReg = new Regex(@"(?<time>(\d|\:)+)\s" + @"(?<company>\S+)\s" + @"(?<ip>(\d|\.)+)\s" + @"(?<company>\S+)\s");
MatchCollection theMatches = theReg.Matches(string1);
foreach (Match theMatch in theMatches)
{
if (theMatch.Length != 0)
{
Console.WriteLine("the Match: {0}", theMatch.ToString());
Console.WriteLine("time: {0}", theMatch.Groups["time"]);
Console.WriteLine("ip: {0}", theMatch.Groups["ip"]);
Console.WriteLine("company: {0}", theMatch.Groups["company"]);
foreach(Capture cap in theMatch.Groups["company"].Captures)
{
Console.WriteLine("cap: {0}",cap.ToString());
}
}
}
Console.ReadKey();
}
}
}
Dlaczego powyższy kod z wyrażeniami regularnymi nie działa i mi nic nie wyświetla? Jak sprawdzam w debugerze obiekt theMatches to w polu Results view pokazuje "Wyliczenie nie dalo wynikow".