Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get the latest update time?
#1
Hi,

I'm ran into a problem with an application i'm using that stores previous updates, as the updates are stored in random order instead of showing the latest updates first. Below is an example of the update list.

Quote:10/02/10 13:46:50 (User):
Update Message 1.
TextTextText

10/02/10 13:48:55 (User):
Update Message 3.
Text TextTextTextTextTextText
TextTextTextTextTextText

10/02/10 13:47:12 (User):
Update Message 2.

Because the updates are ordered randomly ordered i'm looking to use regex to find them and then display the latest update time. Is this possible?

Below is the code i'm using to display an array of the update times:

Code:
Copy      Help
str updates="10/02/10 13:46:50 (User):[]Update Message 1.[]TextTextText[][]10/02/10 13:48:55 (User):[]Update Message 3.[]Text TextTextTextTextTextText[]TextTextTextTextTextText[][]10/02/10 13:47:12 (User):[]Update Message 2."
str pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \(.*?\)\:"

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

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

This then outputs:

Quote:0 10/02/10 13:46:50 (User):
1 10/02/10 13:48:55 (User):
2 10/02/10 13:47:12 (User):

From here i'm lost, how can I get the date & time of the latest update?

Regards,

Paul.
#2
Macro Macro1275
Code:
Copy      Help
str updates=
;10/02/10 13:46:50 (User):
;Update Message 1.
;TextTextText
;
;10/02/10 13:48:55 (User):
;Update Message 3.
;Text TextTextTextTextTextText
;TextTextTextTextTextText
;
;10/02/10 13:47:12 (User):
;Update Message 2.

str pattern="([0-9]{2}\/[0-9]{2}\/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}) \(.*?\)\:"

ARRAY(str) a
int i
findrx(updates pattern 0 4 a)

DATE d dd
for i 0 a.len
,dd=a[1 i]
,if(dd>d) d=dd

out d ;;the latest update


Forum Jump:


Users browsing this thread: 1 Guest(s)