« Previous Next »

Thread: Break string

Last post 07-10-2009 6:03 PM by hg363. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 07-09-2009, 3:46 PM

    • hg363
    • Top 100 Contributor
    • Joined on 09-04-2007, 3:44 PM
    • Posts 54

    Break string

    Hi to all forum members. Can some one please assist me. I am using LP to interrogate a text file and pull out TEXTLINE data. Here is an example

    204   00:13:21:5f:04:d4     learned              0     bridging      1/9

    Is there any clever way of telling LP that when it finds this data to break it down like this

    204

    00:13:21:5f:04:d4    

    learned             

    0    

    bridging     

    1/9

    and if there is please can some one give me an example and demonstrate how this can be done, need this last bit to complete a project. Regards hg363 UK

  • 07-10-2009, 3:50 AM In reply to

    • kateroh
    • Top 50 Contributor
    • Joined on 10-27-2008, 11:19 PM
    • Posts 137

    Re: Break string

    using (StringReader reader = new StringReader(logText))
    {
       string line;
       // read line by line
       while ((line = reader.ReadLine()) != null)
       {
            // split each line into pieces
            string[] linePieces = line.Split(' ');
       }
    }

    Thanks,
    Katerina Rohonyan, SDET, Microsoft IIS Team
  • 07-10-2009, 4:13 AM In reply to

    • hg363
    • Top 100 Contributor
    • Joined on 09-04-2007, 3:44 PM
    • Posts 54

    Re: Break string

    Hi thank you very much for your prompt answer but I suspect the answer you have provided is resolving my problem using some form of programming language. Can this be achieved directly by Log Parser or vbscript? Thank you Mr Ghelani

  • 07-10-2009, 5:25 PM In reply to

    • kateroh
    • Top 50 Contributor
    • Joined on 10-27-2008, 11:19 PM
    • Posts 137

    Re: Break string

    Oh, sorry, it was C#. Here is VB:

    Dim reader As StringReader = New StringReader(logText)
    Dim line As String = reader.ReadLine()

    While (line Is Not Nothing)
        
    Dim linePieces() As String = line.Split(Microsoft.VisualBasic.ChrW(32))
        line 
    reader.ReadLine()
        
    End While

    Thanks,
    Katerina Rohonyan, SDET, Microsoft IIS Team
  • 07-10-2009, 6:03 PM In reply to

    • hg363
    • Top 100 Contributor
    • Joined on 09-04-2007, 3:44 PM
    • Posts 54

    Re: Break string

    Hi look thank you very much indeed  for taking the time to show me. May I please ask more question as I very new to LP, how would one pass the TEXTLINE found by LP to this script. So weather I use this method

    objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat

    or this method

    objShell.run ("LogParser " & string_is)

    how when LP finds that data I am looking for do I then get LP to pass it to the script, please will you kindly show me kind regards HG UK

     

     

Page 1 of 1 (5 items)
Microsoft Communities