How to extract and print the fields in following pattern: The fields are,date,time ip address,user agent cookies ,byte,refer etc(This is a log file)
[03/Dec/2013:10:53:59 +0000] - [32002 10.102.4.254 126.96.36.199 Up24RwpmBAwAAA1LWJsAAAAR GET /content/dam/original.jpg HTTP/1.1] _utmc=94539802; dtCookie=EFD9D09B6A2E1; dtPC=load; Carte::Kertdomain=6701c1320dd99722; UserData=Username:LSHARMA:Homepageg:0; etc etc....
Any one help me? Which method is used for this application?
[edit, code tags, koahnig]
A good start would be "QString::split functionality.":http://qt-project.org/doc/qt-5/qstring.html#split When used with ';' as separator you will already split into the major section pieces as it looks. A more advanced method would be using the variations with "QRegExp":http://qt-project.org/doc/qt-5/qregexp.html or the new "QRegularExpression":http://qt-project.org/doc/qt-5/qregularexpression.html . However, this depends a bit on how much automation and sophistication you like to have.
This is only one type of log.About my project log analysis(It analyze different types of log).The QRegExp is easy method or not in my project?i go through the QRegExp.But the project time is very short and also am new in Qt.So Can you split the above log file?If you split the above log file i can get the clear idea and i will follow the same method in other log file case.
So can you help me?
It is a philosophic discussion whether regular expressions are easy to use or not.
If you have never done anything with regular expressions and you have to do your job quickly, I would not recommend regular expressions. It is certainly something to get used to.
Regular expressions are very powerful, but a bit complex. Anyway for regular expressions there is an "example":http://qt-project.org/doc/qt-5/qtwidgets-tools-regexp-example.html given. I found it quite useful for testing my regular expressions with an example line.