PDA

View Full Version : bpcode error checking


chrispadfield
Thu 23rd Nov '00, 10:33pm
How about some basic error checking for bpcode. Ie for every open tag there must be a closed one. If there is not then instead of posting the page goes to a preview page with the post there ready for editing.

This idea is adapted from the "force preview" thread.

chrispadfield
Thu 23rd Nov '00, 10:34pm
of couse meant vbcode.. back to my days of boardpower.. now if only i could edit the threadt title :)

Mas*Mind
Fri 24th Nov '00, 7:06am
I've created regexes that only will be parsed when they are closed...The only problem is that they require php > 3.09

$bbcode=preg_replace("/(\[url=)(.*)(])(.*)(\[\/url\])/siU", "<a href=\"\\2\" target=_blank>\\4</a>",$bbcode);

or

$bbcode=preg_replace("/(\[url])(.*)(\[\/url\])/siU", "<a href=\"\\2\">\\2</a>",$bbcode);

etc...

Works flawlessly with every possible combination of multiple bbcodes (nested, multiple etc..)

[Edited by Mas*Mind on 11-24-2000 at 11:50 AM]

chrispadfield
Fri 24th Nov '00, 12:20pm
brilliant! i will be adding this!