Checking if a string contains a image

Would it be possible to detect if a string has an image in it. For example,
‘This is an image, talkwalker.com/images/2020/blog-headers/image-analysis.png’.
Then put this image into an

<img src={stringsource} />

And also keep the previous text that was there.
For example, i tried doing something like

const msgstring = 'Hello how are you, check out this image 
https://www.talkwalker.com/images/2020/blog-headers/image-analysis.png'
msgstring.replace(msgstring.slice(msgstring.indexOf('http'), msgstring.indexOf('png')+3),`<img src=${msgstring.slice(msgstring.indexOf('http'), msgstring.indexOf('png')+3)}>`)

But this is a static and not very good solution because it only works for images ending in png and they must start in http, or else the source will be invalid.

143 thoughts on “Checking if a string contains a image”

  1. What i do not realize is in reality how you are now not actually a lot more neatly-preferred than you might be now.
    You’re so intelligent. You understand therefore considerably in the case of this subject, produced
    me personally believe it from so many varied angles. Its like women and men are not involved until it’s one thing to do with Lady gaga!
    Your personal stuffs nice. Always deal with it up! http://droga5.net/

    Reply
  2. Pingback: stromectol 6