regular expression not behaving as expected - Python
- by philippe
I have the following function which is supposed to read a .html file and search for <input> tags, and inject a <input type='hidden' > tag into the string to be shown into the page.
However, that condition is never met:( e.g the if statement is never executed. ) What's wrong with my regex?
def print_choose( params, name ):
filename = path + name
f = open( filename, 'r' )
records = f.readlines()
print "Content-Type: text/html"
print
page = ""
flag = True
for record in records:
if re.match( '<input*', str(record) ) != None:
print record
page += record
page += "<input type='hidden' name='pagename' value='psychology' />"
else:
page += record
print page
Thank you