def tag_regex(tagname):
 return dict(open=('(?:<\\s*%(t)s\\s+[^<>]*?>|<\\s*%(t)s\\s*>)' % dict(t=tagname)), close=('</\\s*%(t)s\\s*>' % dict(t=tagname)))

def tag_regex ( tagname ) : return dict ( open = ( '(?:<\\s*%(t)s\\s+[^<>]*?>|<\\s*%(t)s\\s*>)' % dict ( t = tagname ) ) , close = ( '</\\s*%(t)s\\s*>' % dict ( t = tagname ) ) )
return non-grouping regular expressions that match the opening and closing tags for tagname .