0

i have a variable "html" with an HTML code.

I need to extract:

<h4 class="search-results-count">ANY TEXT THAT GOES HERE</h4>

but i can't figure how to do that with regex or another tecnique

karthik manchala
  • 13,492
  • 1
  • 31
  • 55
Alan Daitch
  • 79
  • 2
  • 12

2 Answers2

2

You can extract the innerHTML like

document.querySelector('.search-results-count').innerHTML
Zee
  • 8,420
  • 5
  • 36
  • 58
0

You should not parse html with regex

You can use the following regex: (not recommended)

<h4[^>]*>([^<]*)<\/h4>

And extract group 1.. $1

See demo

Community
  • 1
  • 1
karthik manchala
  • 13,492
  • 1
  • 31
  • 55