def scrub_relative_urls(html):
 try:
  return re.sub(u'src[\\s]*=[\\s]*[\'"]files/([^\'"]*)[\'"]', u'src="/files/\\g<1>"', html)
 except:
  print u'Error', html
  raise

def scrub_relative_urls ( html ) : try : return re . sub ( u'src[\\s]*=[\\s]*[\'"]files/([^\'"]*)[\'"]' , u'src="/files/\\g<1>"' , html ) except : print u'Error' , html raise
prepend a slash before a relative url .