Hello evryone
i need aregex code that replacing
url: http://domain.com at
link: <a href="http://domain.com" rel="nofollow">http://domain.com</a>

replace the url until space

Recommended Answers

All 2 Replies

Member Avatar for diafol
$url = "http://www.diafol.org";
echo preg_replace("/(http:\/\/\S+)\s*/","<a href=\"$1\" rel=\"nofollow\">$1</a>",$url);

that'll work on the simplest of urls. check out url matches, e.g. ftp, https, with querystrings and username/pw and anchor hashes etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.