Jump to content

Recommended Posts

Im running out of ideas how to do a certain thing with a file so figured i may as well ask more expierienced crowd :)

 

Im trying to write a web based log parser in which lines may have different templates for parsing, without manually splitting the data inside the file by adding delimiters.

The general idea is to split the string in a way i could get all the needed data like [date] [name] [effect] [action] [target] [did] [type], [date] [name] [effect], [date] [name] [action] so i can save them into variables and then create a table from those for calculations. Now the problem is that name, action, target etc can be more than one word.

For eg.:

[00:00:01] Big Joe's Hand Wave waves at Little Dee for 5 seconds. 
[00:00:05] Little Dee gains Being Waved At. 

 

From such lines id like to get:

$date = 00:00:01, $name = Big Joe, $used = Hand Wave, $action = waves, $target = Little Dee, $did = 5,  $type = seconds

and

$date = 00:00:05, $name = Little Dee, $action = gains, $effect = Being Waved At

 

Is there a way to split the line without making first database of names, effects etc, maybe by checking for capital letter at start of each word to group them into variables ? Since Name, Effect and Target will always be capital and Name will be separated from following  either by 's or by action, then just database for the few types of actions

Link to comment
https://forums.phpfreaks.com/topic/173208-log-parsing-without-delimiters/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.