با عرض سلام و خسته نباشید خدمت کاربران وب سایت پروگرم 98 😉 در این پست کد Regex و Capture Collection در سی شارپ #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد Regex و Capture Collection در سی شارپ #C :
using System;
using System.Text.RegularExpressions;
class Test
{
public static void Main()
{
string string1 = "04:03:27 abc 0.0.0.127 def";
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)
using System.Text.RegularExpressions;
class Test
{
public static void Main()
{
string string1 = "04:03:27 abc 0.0.0.127 def";
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)