def anchor_map(html):
 ans = {}
 for match in re.finditer(u'(?:id|name)\\s*=\\s*[\'"]([^\'"]+)[\'"]', html):
  anchor = match.group(1)
  ans[anchor] = ans.get(anchor, match.start())
 return ans

def anchor_map ( html ) : ans = { } for match in re . finditer ( u'(?:id|name)\\s*=\\s*[\'"]([^\'"]+)[\'"]' , html ) : anchor = match . group ( 1 ) ans [ anchor ] = ans . get ( anchor , match . start ( ) ) return ans
return map of all anchor names to their offsets in the html .