thehigherentity Posted May 27, 2006 Share Posted May 27, 2006 I am trying to make a form that allows BBCODE type inputso far it works but there are a couple of problems i cant work outone is when a link is submitted starting with www. it is converted with the following code to a showable link but I dont know how to make it work with the http:// on the beggining[code]$url = preg_replace("/\[url=(\W?)(.*?)(\W?)\](.*?)\[\/url\]/i", '<a class="bbcode_links" href="http://$2">$4</a>', $url); // change bbcode links[/code]I know i could str_replace it out but I cant make it work on a mix of lower and upper case lettersis there a way i can work it into the above preg_replace so it would remove the http:// at the same time as changing the code over to a html link?my other problem is white spaces[mytags] <<<< I have many of these tag names and need the code to work on them all so like the above code recognisses the [ ] to know its a tag, i need somthing like this for removing the white space I want a way to remove all spaces from between [ mytags ] << them tags so i would end up with [mytags]so even if the input was [ m y t a g s ] it would still come out as [mytags] it would also be great if i could remove new lines and breaks etc from inside them tags too.at the same time i need to fine a way of doing cind of the same thing with the text outside the tags but not all the spaces just the leading and ending space eg[mytags] blah blah blah [/mytags] would become [mytags]blah blah blah[/mytags] i dont want to remove new lines or anything with this part thoughplease help it has taken me days to work out the rest and its realy not far from finnished now this is just about my last problem Quote Link to comment https://forums.phpfreaks.com/topic/10553-need-help-with-preg_replace/ Share on other sites More sharing options...
GingerRobot Posted May 28, 2006 Share Posted May 28, 2006 Not sure how you would accomplish all of this, it would seem like a large number of explode and implode functions to me...However, if you having problems with case sensitivity with str_replace(), use:str_ireplace(PHP 5)str_ireplace -- Case-insensitive version of str_replace(). Quote Link to comment https://forums.phpfreaks.com/topic/10553-need-help-with-preg_replace/#findComment-39736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.