I have string content html example:
Yjgbhg <img id="image1" src="https://dzlvqfm687ile.cloudfront.net/5940_image-0878eae8-e316-46fc-a776-b3d22e292c55.jpg">Huyju <video src="https://dzlvqfm687ile.cloudfront.net/5824_video.mp4" id="video1" onclick="blurEditor();" onplay="blurEditor();" controls=""></video>
I want pass string to object same
[
{
type: "text",
value: "Yjgbhg"
},
{
type: "img",
value: "https://dzlvqfm687ile.cloudfront.net/5940_image-0878eae8-e316-46fc-a776-b3d22e292c55.jpg"
},
{
type: "text",
value: "Huyju"
},
{
type: "text",
value: "https://dzlvqfm687ile.cloudfront.net/5824_video.mp4"
},
]
I try used
var regexp = /<img[^>]*src="?([^"\s]+)"?\s*\/>/g;
console.log(regexp.exec( strHtml ));
while ( m = regexp.exec( text ) ) {
urls.push( m[0] );
}
var regexp = /<video[^>]*src="?([^"\s]+)"?\s*\/>/img;
while ( m = regexp.exec( text ) ) {
urls.push( m[0] );
}
console.log(urls);
to get img and video but it return array null. How I can do it?