vntale Posted September 5, 2009 Share Posted September 5, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/173208-log-parsing-without-delimiters/ Share on other sites More sharing options...
Daniel0 Posted September 5, 2009 Share Posted September 5, 2009 That's going to be difficult unless you can teach PHP to speak English. Quote Link to comment https://forums.phpfreaks.com/topic/173208-log-parsing-without-delimiters/#findComment-913023 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.