String Template

t.giuseppe at t.giuseppe at
Fri Dec 27 13:55:00 CET 2013


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: - [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: Gecko/20101026 Firefox/3.6.12 "

Is there any way to pull out the values so arranged as follows:

ip =
date = 27/Dec/2013: 00:56:51 +0100
url = / webdav /


More information about the Python-list mailing list