Help with tables in a wiki

Hey again,

I’m in the process of adding/fixing a tables feature for my wiki and i was wondering how’d i’d convert the following syntax into working tables using RegEx:

[TABLE]
r1c1|r1c2|r1c3|
r2c1|r2c2|r2c3|
r3c1|r3c2|r3c3|
[/TABLE]

if there is nothing (or a newline) after a “|”, then close the row and go on to the next row (as long as the beginning of the next row isn’t a [/TABLE].

Also, if its the first row, I need to know it so that I can give the “header” a different BG-color.

By the way, earlier in the code, i substituted all "
" for "*br />, in case that matters.

Thanks in advance!
Matt