Big problem - Regular Expression

Hi I'm trying to build an regular expression to read this data

Thu Jun 22 08:08:16 2006
Acct-Session-Id = "00001023"
Cisco-AVPair = "call-id=226F99C2-11611DB-856D832F-210CC2EB@10.0.11.31"
Cisco-AVPair = "iphop=count:1"
Cisco-AVPair = "iphop=hop1:10.0.11.31"
h323-setup-time = "11:07:31.687 UTC Thu Jun 22 2006"
h323-gw-id = "Celular32."
h323-conf-id = "1FE0AF6C 011611DB 856A832F 210CC2EB"
h323-call-origin = "answer"
h323-call-type = "VoIP"
Cisco-AVPair = "h323-incoming-conf-id=1FE0AF6C 011611DB 856A832F 210CC2EB"
Cisco-AVPair = "subscriber=Unknown"
Cisco-AVPair = "session-protocol=sipv2"
Acct-Input-Octets = 276960
Acct-Output-Octets = 277600
Acct-Input-Packets = 1731
Acct-Output-Packets = 1735
Acct-Session-Time = 12
h323-connect-time = "11:07:57.739 UTC Thu Jun 22 2006"
h323-disconnect-time = "11:08:09.339 UTC Thu Jun 22 2006"
h323-disconnect-cause = "10 "
h323-remote-address = "10.0.11.31"
h323-voice-quality = "0"
Cisco-AVPair = "remote-media-address=10.0.11.31"
Cisco-AVPair = "gw-rxd-cdn=96633438"
Cisco-AVPair = "gw-rxd-cgn=1140668686"
User-Name = "1140668686"
Acct-Status-Type = Stop
Calling-Station-Id = "1140668686"
Called-Station-Id = "96633438"
Service-Type = Login-User
NAS-IP-Address = 10.0.11.32
Acct-Delay-Time = 0
Client-IP-Address = 10.0.11.32
Acct-Unique-Session-Id = "e6614a0dd894edc5"
Timestamp = 1150974496

Thu Jun 22 08:08:16 2006
Acct-Session-Id = "00001024"
h323-setup-time = "11:07:31.707 UTC Thu Jun 22 2006"
h323-gw-id = "Celular32."
h323-conf-id = "1FE0AF6C 011611DB 856A832F 210CC2EB"
h323-call-origin = "originate"
h323-call-type = "Telephony"
Cisco-AVPair = "h323-incoming-conf-id=1FE0AF6C 011611DB 856A832F 210CC2EB"
Cisco-AVPair = "subscriber=Unknown"
Cisco-AVPair = "out-intrfc-desc="
Acct-Input-Octets = 277760
Acct-Output-Octets = 276960
Acct-Input-Packets = 1736
Acct-Output-Packets = 1731
Acct-Session-Time = 12
h323-connect-time = "11:07:57.735 UTC Thu Jun 22 2006"
h323-disconnect-time = "11:08:09.355 UTC Thu Jun 22 2006"
h323-disconnect-cause = "10 "
Cisco-AVPair = "h323-ivr-out=Tariff:Unknown"
h323-voice-quality = "0"
Cisco-AVPair = "gw-rxd-cdn=96633438"
Cisco-AVPair = "gw-rxd-cgn=1140668686"
Cisco-AVPair = "gw-final-xlated-cdn=96633438"
Cisco-AVPair = "gw-final-xlated-cgn=1140668686"
User-Name = "1140668686"
Acct-Status-Type = Stop
NAS-Port-Type = Async
Cisco-NAS-Port = "FXO 2/0"
NAS-Port = 0
Cisco-AVPair = "interface=FXO 2/0"
Calling-Station-Id = "1140668686"
Called-Station-Id = "96633438"
Service-Type = Login-User
NAS-IP-Address = 10.0.11.32
Acct-Delay-Time = 0
Client-IP-Address = 10.0.11.32
Acct-Unique-Session-Id = "da2ab3d9d506cd1a"
Timestamp = 1150974496

But it's to dificult, can anyone give me a hand

Thanks




Answer this question

Big problem - Regular Expression

  • bb35

    Ok thanks..

    i've already solved...

    Hehe What a work...



  • Maaryaam

    String TmpInput = TmpSTream.ReadToEnd();


  • Mandypenny

    You can probably just read line by line and do a String.Split on the equals, then just create the dataset row by row...



  • nx797rd

    But I'm reading a file like this..

    StreamReader freader = File.OpenText(arquivo);

    how can I use the freader in this situation

    Thanks a lot



  • theresa valentine

    How about writing a regular expression for each line, instead You could even reuse regular expressions for certain lines, or just make one generic regex that parses a line into a name/value pair and disregaurds the quote if present.
  • Qaiser Mehmood Mughal

    OK thanks...

    I need to put this data into a DataTable



  • Andy Perkins

    Regex TmpReg = new Regex(@"^(.[^ =]*) = (.*)\n$", RegexOptions.Multiline);
    MatchCollection Matches = TmpReg.Matches(TmpInput);
    for (Int32 i=0; i<Matches.Count; i++)
    {
    Console.WriteLine(Matches[ i ].Groups[1].Value + "\t\t" + Matches[ i ].Groups[2].Value);
    // Matches[ i ].Groups[1].Value is the name on the left
    // Matches[ i ].Groups[2].Value is the value on the right.
    }


    Make sure you have a
    using System.Text.RegularExpressions;

    Hope this helps

  • Big problem - Regular Expression