×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

C# (C Sharp) example - C# Regular expressions: Example of creation of Groups and using Group classes


C# (C Sharp) - C# Regular expressions: Example of creation of Groups and using Group classes

string strText="212.56.87.23 netartmedia.net";
 
Regex oRegex=new Regex(@"(?<IP_ADDRESS>(d|.)+)s"+@"(?<URL>S+)");
 
MatchCollection oMatchCollection=oRegex.Matches(strText);
 
foreach(Match oMatch in oMatchCollection)
{
 
 Console.WriteLine("IP: "+oMatch.Groups["IP_ADDRESS"]);
 Console.WriteLine("URL: "+oMatch.Groups["URL"]);
}
 
/*
 * 
 will print to the screen
 
 IP: 212.56.87.23
 URL: netartmedia.net
 
 */

Category: C# (C Sharp)

 
<< Go back