Wow, that regex is horrible! As of 2016, there is a .getAttribute()
method for each DOMElement
that makes things a bit easier, but you still have to iterate through the elements.
l = []
for e in elements:
if e.hasAttribute('name') and e.getAttribute('name') == 'field.len':
l.append(e)