A snip from the log file looks as follows:
(1140157349)[Fri Feb 17 06:22:29 2006] Logging to 'logs/ServerName/eq2log_Character.txt' is now *ON* (1140157367)[Fri Feb 17 06:22:47 2006] You start fighting. (1140157367)[Fri Feb 17 06:22:47 2006] YOU hit a Bitterwind pioneer for 126 points of piercing damage. (1140157370)[Fri Feb 17 06:22:50 2006] a Bitterwind pioneer's Ball of Fire hits YOU for 260 points of heat damage. (1140157375)[Fri Feb 17 06:22:55 2006] a Bitterwind pioneer hits YOU for 91 points of crushing damage. (1140157377)[Fri Feb 17 06:22:57 2006] YOUR Crushing Anvil hits a Bitterwind pioneer for 89 points of crushing damage. (1140157423)[Fri Feb 17 06:23:43 2006] You have killed a Bitterwind pioneer. (1140157423)[Fri Feb 17 06:23:43 2006] You stop fighting.
There is alot of useless banter in amogst those lines as well but I don't need thos, so I cut them from the overview.
I need to do a few things with this file:
1. Extract that line that says "Logging to .....*ON*", and extract the "Character" from it (this changes depending on who is logged in).
2. Replace all the "YOU" and "YOUR" with the name of the person who is logged in.
I then need to fill 2 tables. 1 with the damage data, and one with the fight data. The fight table will be something like:
The start time would be "1140157367" in the example above, so I need to grab the numeric between () at the start of the line that contains the text "You start fighting". The end time would be the numeric between () at the start of the line that contains the test "You stop fighting".
I'm havign some issues figuring out how to actually grab that number. Should I do some sort of rexexp that finds "You start fighting" and then drop the whole line except the numeric? Or are there better ways?
The other table with the damage would do a simular thing per line, splitting it up into the needed fields, so once I find a solution for the start/end of a fight I should be able to port that to the other data.
I know this is vague and has no code at all, but as I can't see how to start doing this I haven't started coding at all
I had a look at a BBCode editor I have written for another site, to see if I can adapt that. But appart from the way it handles the data - in this case from a from - by stuffing it into a variable and then converting parts, which could be used to replace You/Your, I don't see how this code helps me much...
Does anyone have a sugestion on how to go about this? Or a pointer at what docs I might want to read?