1

I need to be able to get all content between any html tag. Currently I am using:

var result = data.match(/<p>(.*?)<\/p>/g).map(function(val){
 // validate
}

The closest I have got is: <[a-z1-9]{1,10}>(.*?)<\/[a-z1-9]{1,10}>

However looking at a regex tester, it is not correct.

It's not closing on matching tags and is even missing some out, what am I missing?

My aim is to get anything between all tags not between a certain two.

https://regex101.com/r/jR7wZ3/1

Eli Stone
  • 1,515
  • 4
  • 33
  • 57

1 Answers1

0

Thanks to @WiktorStribiżew

var el = document.createElement( 'faketag' );
el.innerHTML = txt;
var arr = [];
[].forEach.call(el.childNodes, function(v,i,a) {
        arr.push(v.innerHTML);
});
console.log(arr);

https://jsfiddle.net/uncysdv4/1/

Eli Stone
  • 1,515
  • 4
  • 33
  • 57