[Python-de] String in Datei ersetzten
Christopher Arndt
chris.arndt at web.de
Wed Feb 6 16:48:18 EST 2002
ipaddr="172.16.10.55"
start_re = re.compile(r'^\s*#?<VirtualHost\s+' + ipaddr + r'>\s*$')
Dazu muss ipaddr natürlich eine *String* Variable sein. Die regular
expression strings sollten "raw" strings (mit vorangestelltem 'r') sein
(wegen der backslashes).
Felix Seeger wrote:
> Mhm, funktioniert ziemlich gut, ich hab nur noch ein re Problem.
> Wie ersetzte ich die IP 172.16.10.55mit einer Variablen:
> start_re = re.compile(r'^\s*#?<VirtualHost\s+172.16.10.55>\s*$')
>
> mit + das ganze aus strings zusammensukleben hat nicht funtioniert.
> _______________________________________________
> Python-de maillist - Python-de at starship.python.net
> http://starship.python.net/mailman/listinfo/python-de
>
More information about the Python-de
mailing list