How to write BB codes? I know it is easy, but the problem is: when you write [B]тест[/B]
, everything is in order, and when [B]тест...
then the whole text is bold. How to make a filter, so that if there is [B]
, but there is no [/B]
, then [B]
removed from the text? Or it gave an error: end the tag.
- At the idea level: with a regular expression, count the number of open tags minus the number of closed tags. If something is not enough - to add. - ling
|
1 answer
- make a replacement for the regular expression for all paired tags.
- remove all that did not pass autochange.
The last item, for example, is:
preg_replace('/\[[^\[\]]\]/','',$str);
I mean, delete all the square brackets and everything in between.
- [script src = " mysite.com/stealcook.js"[[/script] - Alex Kapustin
- yeah This will happily transform if the script tag is enabled, or destroyed, if disabled - knes
|