What I want to do is find the tag that has the string "test string" even when that tag is nested inside other tags.
<section class="test-class1"><div><p class="test-class2">something else....test string</p></div></section>
< *(\w+)[^<>]*>[^<]*(?:<[^>]*)*test string
p in the first capturing group (
$1). Is not possible to speed it up so much. You'd better to use pure JS functions.