I'm running out of ideas on the best regex implementation for this problem.
User input example:
bla bla bla http://foo.com bla bla bla http://tinypic.com/boo.png bla bla bla
You are looking for a solution that will detect a URL without an image and turn it into a link, and also turn the image URL into an embeddable image (IMG tag).
so the output will be:
bla bla bla <a href="http://foo.com"> http://foo.com </a> bla bla bla <img src = "http://tinypic.com/boo.png" /> bla bla bla
Related
- Regex for validating a URL that ends in .jpg, .png or .gif
- What is the best regex to check if a string is correct?
- Retrieving URL Parts (Regex)
url php regex image
alvin
source share