I'm looking for a solution to use regex in BeautifulSoup to find elements that may contain the text HO # with possible spaces and ignoring case sensitivity.
check_ho_number3 = soup.select_one('td:-soup-contains("HO #")+ td')
print(check_ho_number3)
How can I integrate my existing regex expression into soup.select_one()?
check_regex = re.compile("HO\s?#",re.IGNORECASE)
CSS SELECTORSonly supports CSS syntax but you can search by tag content with thestringproperty:To
findNextSibling('td')step back to theparentof your located object.Example