def find_nodes_with_matching_text(page, xpath, regex):
 xpath_matches = page.xpath(xpath)
 results = []
 for xp in xpath_matches:
  if re.search(regex, xp.text_content()):
   results.append(xp)
 return results

def find_nodes_with_matching_text ( page , xpath , regex ) : xpath_matches = page . xpath ( xpath ) results = [ ] for xp in xpath_matches : if re . search ( regex , xp . text_content ( ) ) : results . append ( xp ) return results
using an lxml node .