HaLo2FrEeEk Posted March 8, 2007 Share Posted March 8, 2007 Hey, I'm creating a very simple Content Management System in which I will be pulling out the first 200 characters from every topic in a certain forum for which the subject is "Weekly Update: %" (% being wildcard,) my question is this: when someone enters some post into the forum, it stores it in the database with a post_id, all bbcode is then appended with a unique uid, it looks something like this: [img:d4fa0dddab]http://claninfectionist.com/images/misc/deadcount21000.png[/img:d4fa0dddab] I want to remove the :% (again, using % as wildcard) from the bbcode to display it normally, I will then do str_replace to replace all bbcode tags with their html counterparts, or at least the more important ones, like bold, italic, underline, image, and link. Any idea how I can do this? PS. I don't know how to use wildcards in str_replace, but I have seen something of them, will this work with this: $result = str_replace("[img:^(.*)]", "[img]", $result) This example uses just the image tag, but would that work? Edit: This doesn't work, I tried it, and the uid is still there. Anything else I can try? Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/ Share on other sites More sharing options...
HaLo2FrEeEk Posted March 8, 2007 Author Share Posted March 8, 2007 Please? anyone? Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-202342 Share on other sites More sharing options...
fert Posted March 8, 2007 Share Posted March 8, 2007 try this $result = preg_replace("[img:(.*)]", "[img]", $result); Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-202344 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 8, 2007 Author Share Posted March 8, 2007 Uuuurgh, it...kinda works. It replaces it, but it turns: [img:868416aced]http://claninfectionist.com/tutorials/photoshop/FireText/untitled18.png[/img:868416aced] Into: [ For some reason. Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-202373 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 8, 2007 Author Share Posted March 8, 2007 Can someone please help me? Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-202852 Share on other sites More sharing options...
sasa Posted March 8, 2007 Share Posted March 8, 2007 try <?php $result =' [img:868416aced]http://claninfectionist.com/tutorials/photoshop/FireText/untitled18.png[/img:868416aced]'; echo $result1 = preg_replace("[[/]*img:[^\]]+]", "img", $result); echo "\nor"; echo $result2 = preg_replace("[img:[^\]]+]", "img", $result); ?> Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-202896 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 8, 2007 Author Share Posted March 8, 2007 The second one, it worked like a freaking charm, thank you. I had to midify it just a bitm but it worked great. Link to comment https://forums.phpfreaks.com/topic/41728-removing-bbcode-uid-user-id/#findComment-203030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.