DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 <?php $oldstring = "[url=bob.php]bob[/url]"; $oldstring = eregi_replace("\[url=([^\[]+)\]([^\[]+)\][/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>", $oldstring); echo $oldstring; ?> this code is not doing anything, i don't know why it doesnt work, when i echo it it just says bob, anyone any ideas or can someone convert to preg_replace if need be? Link to comment https://forums.phpfreaks.com/topic/115513-solved-eregi_replace-not-working-convert-to-preg_replace/ Share on other sites More sharing options...
effigy Posted July 18, 2008 Share Posted July 18, 2008 <pre> <?php $oldstring = '[url=bob.php]bob[/url]'; echo $oldstring = preg_replace( '%\[url=([^\]]+)\]([^\[]+)\[/url\]%', '<a href="$1" target="_blank">$2</a>', $oldstring ); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/115513-solved-eregi_replace-not-working-convert-to-preg_replace/#findComment-593837 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Author Share Posted July 18, 2008 thanks, but i have just got it working ,there was an error in it. this is the code $code = eregi_replace("\+)\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$code); Link to comment https://forums.phpfreaks.com/topic/115513-solved-eregi_replace-not-working-convert-to-preg_replace/#findComment-593846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.