Problem with regexp and text injection

Panagiotis Atmatzidis p.atmatzidis at gmail.com
Mon Oct 22 00:22:56 CEST 2007


Hello,

I want to create a script in python that search for .html files in the
predefined directory and subdirectories. Then it checks if a specific
snippet of code exists in the .html file, if not it injects/adds the
code right below the string <body> otherwise bypasses the file.

I wrote the first part, I managed to write search function and I'm
trying to find my way out of regular expressions reading the manuals.
However I don't know what kind of function and module to use in order
to write this function, re.search(), re.string() or re.match() or
maybe re.compile() ?

I have not much programming experience. Programming is not my cup of
tea.

Can someone help by pointing me to a sample code with comments if
possible.

Regards,

atma




More information about the Python-list mailing list