I have a string generated with this format :
'fdffddf<div><br> <div><img style="max-width: 7rem;" src="folder/myimg.jpg"><div> <br></div></div><div><div> <br></div></div></div>'.
I want to create a regular expression . I want a regular expression that just fetches me the content without the div tag and the source of the image in an array.
Example in my case:
[ 'fdffddf', 'folder/myimg.jpg' ]
I tried this method :
let str = 'fdffddf<div><br> <div><img style="max-width: 7rem;" src="folder/myimg.jpg"><div> <br></div></div><div><div> <br></div></div></div>'
console.log('only content without div tag and src image only without img tag : ',str.match(/<img [^>]*src="[^"]*"[^>]*>/gm)[0])
It doesn't work. I get only the img tag.
How can I do it please ?