Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array Help (parse log file)
#1
Hi,

I'm using the below code to try and seperate a list of updates, however the result that I recieve only shows the first line of the update with the date/time, etc. and ends at the line break. I have tried using (?s) at the beginning to include the linebreak, but it then just pulls the whole text as one update. Is there a way I can display the multiple lines on the updates?

Code:
Copy      Help
str html="03/03/2010 08:39:13 Updated by BOND, JAMES[]This is my update.[]Thanks.[][]02/03/2010 12:53:14 Updated by Dr. No[]And this is my update..[][]02/03/2010 12:21:11 Updated by Oddjob[]YAZZAH!"
str pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4} (.*)"

ARRAY(str) a
findrx(html pattern 0 4 a)

int i
for(i 0 a.len)
    out "updated: %s" a[1 i]

Thanks,

Paul.
#2
Macro Macro1288
Code:
Copy      Help
out

str html=
;03/03/2010 08:39:13 Updated by BOND, JAMES
;This is my update.
;Thanks.
;
;02/03/2010 12:53:14 Updated by Dr. No
;And this is my update..
;
;02/03/2010 12:21:11 Updated by Oddjob
;YAZZAH!

str pattern="(?ms)^[0-9]{2}\/[0-9]{2}\/[0-9]{4} (.*?)(?=[][]\d\d/\d\d/\d\d\d\d|\Z)"

ARRAY(str) a
findrx(html pattern 0 4 a)

int i
for(i 0 a.len)
,out "---- updated ----[]%s" a[1 i]

(?m) - ^ matches line beginning, not only whole text beginning.
(?s) - . matches newlines too.
(.+?) - the ? makes to match minimum text. Default is maximum.
(?=[][]\d\d/\d\d/\d\d\d\d|\Z) - must be followed by another date after 2 newlines, or must be end of text.
#3
Thanks Gintaras.

I've been testing this and it works, but it removes the date from the output, is there a way to leave it in?

The output currently shows:

---- updated ----
08:39:13 Updated by BOND, JAMES
This is my update.
Thanks.
---- updated ----
12:53:14 Updated by Dr. No
And this is my update..
---- updated ----
12:21:11 Updated by Oddjob
YAZZAH!
#4
My mistake. Replace a[1 i] to a[0 i].
#5
Worked a treat, cheers.


Forum Jump:


Users browsing this thread: 1 Guest(s)