ajmsake Posted May 17, 2008 Share Posted May 17, 2008 I found this on the net... <?php$text = "this is a paragraph of text with an url embeded. [url="http://www.google.com/"]http://www.google.com/[/url] is a search engine. I'd like to replace the url with the html <a> tag";$text .= " but the below is not working. Another search engine is [url="http://www.yahoo.com/foo/search.html?nothing=nope"]http://www.yahoo.com/foo/search.html?nothing=nope[/url] I keep getting 'Delimiter must"; $text .= " not be alphanumeric or backslash'";preg_replace('\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]', '<a href="\0">\0</a>', $text);?> Any ideas? I'm trying to replace all urls be it starting with http:// with <a href="url">url</a> Link to comment Share on other sites More sharing options...
ajmsake Posted May 17, 2008 Author Share Posted May 17, 2008 I found this on the net...<?php$text = "this is a paragraph of text with an url embeded. [url="http://www.google.com/"]http://www.google.com/[/url] is a search engine. I'd like to replace the url with the html <a> tag";$text .= " but the below is not working. Another search engine is [url="http://www.yahoo.com/foo/search.html?nothing=nope"]http://www.yahoo.com/foo/search.html?nothing=nope[/url] I keep getting 'Delimiter must"; $text .= " not be alphanumeric or backslash'";preg_replace('\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]', '<a href="\0">\0</a>', $text);?> Any ideas? I'm trying to replace all urls be it starting with http:// with <a href="url">url</a> See....! just like it did above in the posting... ugh... Link to comment Share on other sites More sharing options...
ajmsake Posted May 17, 2008 Author Share Posted May 17, 2008 See....! just like it did above in the posting... ugh...while I'm asking, how does one formulate another expression to replace email address to it's mailto: counter part? Link to comment Share on other sites More sharing options...
Synook Posted May 17, 2008 Share Posted May 17, 2008 You match the email address (search Google) and then replace it with <a href="mailto:$0">$0</a>. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.