Trying to get some useful data from a log file with regex in Java -



Trying to get some useful data from a log file with regex in Java -

i'm having problem regex, because can match of goals.

i have log file , must match of items , write txt file. wrote java code short illustration of code when set whole file, gets messed up.

*052511 074217 0065 02242806000 unknown u g *052511 074217 0065 4874 02242806000 unknown u *052511 074218 0065 4874 02242806000 unknown u r -------- 05/25/11 07:42:17 line = 0065 stn = 4874 calling number 02242806000 name unknown unknown bc = speech 00:00:00 incoming phone call ringing 0:02 00:00:11 phone call released

i have find these results file:

incomming,05/25/11,07:42:17,0065,4874,02242806000,00:00:09,2

in look 00:00:09 means [00:00:11-00:00:00]-0:02

for every incoming , outgoing calls, must create conversation above.

here code here log file

you utilize regex like:

(?xm: ^-------- \s+ (\s+) \s+ (\s+) \s+ line\s*=\s*(\d+) \s+ stn\s*=\s*(\d+) \s+ calling\ number \s+ (\d+) \s* (?:^(?:[ \t]+.*)?[\n\r]+)* # eat unwanted part ^(\d\d:\d\d:\d\d) \s+ incoming\ phone call \s+ ringing\ ([\d:]+) \s* (?:^\d.*[\r\n]+)* # possible stuff ^(\d\d:\d\d:\d\d) \s+ call\ released )

use values of capturing groups results. may need remove /x related things comments , spaces.

perl illustration @ http://ideone.com/qtbfe

java regex logging

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -