How do I get the text from the HTML elements using regex and JavaScript? Below are the elements
<div>
<a href="#" onclick="dummyNotToRead()">Dont read</a>
<a href="#" onclick="downLoadPdf('5012102645976')">117/2022</a>
<a href="#" onclick="downLoadPdf('5012102645977')">117/2023</a>
<a href="#" onclick="downLoadPdf('5012102645978')">117/2021</a>
<a href="#" onclick="downLoadPdf('5012102645979')">112/2021</a>
<b> Displaying 1-10</b>
<b>Total no of records: 39</b>
</div>
Here in the above HTML elements how to get onclick and the string present in <b> tag =>Total no of records: 39 by using regex and selector.
Like getting all the <a> anchor tag which is having onclick="downloadpdf()" using regex taking as downloadPdf as teststring and the text which includes "Total no of records:" inside <b> tag using regex.
output is like:in the console.log
downLoadPdf('5012102645976')
downLoadPdf('5012102645977')
downLoadPdf('5012102645978')
downLoadPdf('5012102645979')
For <b>
Total no of records: 39