I have the following string :
this is sample text
[abc def.pdf](https://example.com/post/abc def.pdf)
This is another line after file upload
[dfg.pdf](https://example.com/post/dfg.pdf)

this are some other line append to sting.
I want to convert this string in to as follow.
this is sample text
<a href="https://example.com/post/abc def.pdf">abc def.pdf</a>
This is another line after file upload
<a href="https://example.com/post/dfg.pdf">dfg.pdf</a>
<img src="https://example.com/post/IMG_3261.JPG"/ title="IMG_3261.JPG">
this are some other line append to sting.
How could I do it using laravel or php?
I know I can do that using php function preg_replace but I am not good at REGEXP. So please help me to do it.
what i try so far
i try this solution Why is my PHP regex that parses Markdown links broken?
But it will only converting to anchor tag but i also want to convert it to image tag too
preg_replace('@((https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?))@', '<a href="$1">$1</a>', $string);
but it will not get output i mention above. How can i do it.
github issue.