String Template

Cristiano Araujo yellowcitizen23 at gmail.com
Sat Dec 28 16:11:34 EST 2013


On Friday, December 27, 2013 9:55:00 AM UTC-3, Giuseppe Tripoli wrote:
> Hello
> 
> 
> 
> I'm rewriting a program previously written in C #, and trying to keep the same configuration file, I have a problem with untapped strings.
> 
> 
> 
> The previous configuration files provide an input template string of this type:
> 
> 
> 
> <input> <![CDATA [{ip} - [{date}] "HTTP/1.1 GET {url}" {?} {?} "{referer}" "{useragent}"]]></ input>
> 
> 
> 
> 
> 
> This string is parsed and the values are replaced with the actual values written to a log file (apache), then he is given the variable name.
> 
> 
> 
> Taking for example a classic line of apache log:
> 
> 
> 
> 0.0.0.0 - [27/Dec/2013: 00:56:51 +0100] "GET / webdav / HTTP/1.1" 404 524 "-" "Mozilla/5.0 (Windows, U, Windows NT 5.1, en-US , rv: 1.9.2.12) Gecko/20101026 Firefox/3.6.12 "
> 
> 
> 
> Is there any way to pull out the values so arranged as follows:
> 
> 
> 
> ip = 0.0.0.0
> 
> date = 27/Dec/2013: 00:56:51 +0100
> 
> url = / webdav /
> 
> 
> 
> Tnx

maybe it can be helpful: http://stackoverflow.com/questions/12544510/parsing-apache-log-files



More information about the Python-list mailing list