0

I have this expression:

$content = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $content);

But a link like

http://photoartkalmar.com/Photoart%20Kalmar%20high%20res/Gigapixel/Vienna%2050%20Gigapixel/Donauturm.html

or that ends with something.jpg

The anchor link stops at % or . on the urls, so it doesnt make it all a link only half of it. How can i fix this?

1 Answer 1

2

Of course, put a % symbol in the correct place in the regex: [\w/_\.][\w/_\.%]

Look at this whole line to see exactly where:

$content = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.%]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $content);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.