Î
Îίκος
Two problems here:
str.replace doesn't use regular expressions. You'll have to use the re
module to use regexps. (the re.sub function to be precise)
'.' Â matches a single character. Any character, but only one.
'.*' matches as many characters as possible. This is not what you want,
since it will match everything between the *first* <? and the *last* ?>.
You want non-greedy matching.
'.*?' is the same thing, without the greed.
Thanks you,
So i guess this needs to be written as:
src_data = re.sub( '<?(.*?)?>', '', src_data )
Tha 'r' special char doesn't need to be inserter before the regex here
due to regex ain't containing backslashes.
You will have to find the </body> tag before inserting the string.
str.find should help -- or you could use str.replace and replace the
</body> tag with you counter line, plus a new </body>.
Ah yes! Damn why din't i think of it.... str.replace should do the
trick. I was stuck trying to figure regexes.
So, i guess that should work:
src_data = src_data.replace('</body>', '<br><br><h4><font
color=green> ΑÏιθμός Επισκεπτών: %(counter)d said:No it's not. You're just giving up too soon.
Yes youa re right, your hints keep me going and thank you for that.