Announcement

Collapse
No announcement yet.

strip_bbcode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • strip_bbcode

    The behavior of this function is causing me some problems;

    If I feed it the following ;

    Text [tag]some more text[/tag] end.

    Then I would expect to get back ;

    Text end.

    i.e. It strips the tags and anything inside them.

    What I actually get is

    Text some more text end.

    (it simply removes the tags, not the text between them)

    Is this expected behavior (and if so why ?).
    Baby, I was born this way

  • #2
    I was searching for something like that too, and landed here on this old thread..I am also looking for the way to remove the [tag]content[/tag] as well as the content between the tag..I tried the strip_bbcode function..it's working fine..however I am unable to remove the content between the tag :\ any solution?

    Thanks,
    Best Regards,
    Bilal

    Comment


    • #3
      Originally posted by Bilal View Post
      I was searching for something like that too, and landed here on this old thread..I am also looking for the way to remove the [tag]content[/tag] as well as the content between the tag..I tried the strip_bbcode function..it's working fine..however I am unable to remove the content between the tag :\ any solution?

      Thanks,
      I think there is now a built in fucntion /w vBulletin 3.7 called strip_bbcode, but if you need it

      Code:
      function strip_bbcode($string,$alternate = false){
      		//Alternate Regex Patterns. First one matches anything inside [] while the second matches nothing but A-Z, nos, : , / and =
      		// http://www.neowin.net/forum/index.php?showtopic=193538&st=0&#entry2542818
      		if ($alternate == false){
      			return preg_replace("/'[(.+?)'](.+?)'['/(.+?)']/ism",'$2',$string);
      		}
      		else{
      			return preg_replace("|'[([A-Za-z0'=]*)'](.*?)'[/''1']|ism", "''2", $string);
      		}
      	}
      Credit goes to Google Code Search
      Cr

      Comment


      • #4
        This thread comes first in google. So In case someone is still looking for a way to remove the text in between bbcodes

        PHP Code:
        $String preg_replace("/\[(.+)\](.+)\[(.+)\]/"''$String ); 
        Owner: Oracle Forums - General Discussion Forums.

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X