redbrad0 Posted August 16, 2008 Share Posted August 16, 2008 I really suck at regexp so I am hoping someone can help me out with one expression String Search Google Converted to <a href="http://www.google.com "> Search Google </a> Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/ Share on other sites More sharing options...
redarrow Posted August 16, 2008 Share Posted August 16, 2008 huh? what u mean please give us an example please............... Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/#findComment-617764 Share on other sites More sharing options...
redbrad0 Posted August 16, 2008 Author Share Posted August 16, 2008 sorry i guess this forum uses the same code Starting Code [url="http://www.google.com"]Google[/url] Ending code <a href="http://www.google.com">Google</a> Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/#findComment-617765 Share on other sites More sharing options...
redarrow Posted August 16, 2008 Share Posted August 16, 2008 u mean this mate <?php $txt = preg_replace("/\[url\](.+?)\[\/url\]/", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $txt); $txt = preg_replace("/\(.+?)\[\/url\]/", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $txt); ?> Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/#findComment-617768 Share on other sites More sharing options...
redbrad0 Posted August 16, 2008 Author Share Posted August 16, 2008 I created a test page and I am not sure why... but the second echo does not return any output. Any idea? <?php $htmlversion = "[url=\"www.google.com/search.htm\"]>>>Search Now!<<<[/url]"; echo "htmlversion:" . $htmlversion . "<br>\r\n"; // Try and handle the [url] tag $htmlversion = preg_replace("/\[url\](.+?)\[\/url\]/", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $htmlversion); $htmlversion = preg_replace("/\(.+?)\[\/url\]/", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $htmlversion); echo "htmlversion:" . $htmlversion . "<br>\r\n"; ?> Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/#findComment-617794 Share on other sites More sharing options...
redbrad0 Posted August 17, 2008 Author Share Posted August 17, 2008 Goes anyone have any suggestions on this? Link to comment https://forums.phpfreaks.com/topic/119919-help-with-a-regexp-to-extract-url-and-contents-from-a-bbcode/#findComment-618555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.