Jump to content

Recommended Posts

Hi guys,

 

I've built my own mini BBCode to use with an application, using preg_replace to create the replacements of [][/] that match my array of BBCode samples. I also validate inputs, checking that they're not empty or have too little characters. However, I have hit a problem:

 

If a does something like [ b ][ / b ] (no spaces) it counts towards the total character count, even though it's output is nothing, therefore even if the min character count is 100, just having 20 [ b ][ / b ]'s would go over that and still be blank.

 

How can I remove any BBCode from my string, where it contains nothing inside? I'm thinking I'll need to use preg_replace, like, trim all whitespace from the string and check if [ b ][ / b ] (remove spaces) is there, if it is, remove it.

 

Is this the correct method, or have I made an oversight? :)

 

:-*

Link to comment
https://forums.phpfreaks.com/topic/156253-php-bbcode-checking-for-blank-posts/
Share on other sites

Why write it? http://be.php.net/bbcode

 

I've looked at that, but after installing it it doesn't work. Dunno what the problem is, I'm probably doing something wrong, but right now I just want something that works and this pretty much does, so I'm not changing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.