I'm not real good with regular expressions so I can't really answer your problem directly.
I usually use two arrays to work my preg_replace magic like I learned in this topic:
http://www.astahost.com/php-regular-expessions-t4316.htmlHere is a more recent and simpler example:
I placed certain keywords in strings in my database which are to be replaced by other database entries dependant upon the user.
CODE
// Keyword replacement array here.
$search_string = array ('@&race@si',
'@&rank_suffix@si',
'@&rank@si',
'@&size@si',
'@&username@si',
'@&personal@si',
'@×tamp@si'
);
$replace_string = array ($race,
$rank_suffix,
$rank,
$size,
$username,
$personal,
$time
);
$output = preg_replace($search_string, $replace_string, $sig_text_item_row[$x]['text_value']);
This is about the easiest example I could even think of which just happens to be the one I did today.
Anyway, if the following is true:
CODE
$race = "human";
$rank = 10;
$rank_suffix = "th";
$size = 12000;
$username = "vujsa";
$personal = "My personal message!";
$time = mktime();
AND
CODE
$sig_text_item_row[$x]['text_value']) = "My name is &usernameand I am currently ranked &rank&rank_suffix with an army of &size &race soldiers. <br>&personal<br> Page generated at UTC: ×tamp."
echo $output;
Would return this:
QUOTE(vujsa)
My name is vujsa and I am currently ranked 10th with an army of 12000 human soldiers.
My personal message!
Page generated at UTC: 1131343747
So for your particular example, here is what I would do.
CODE
// Keyword replacement array here.
$search_string = array ('@\[@si',
'@bdc@si',
'@bd@si',
'@bgc@si',
'@cp@si',
'@cs@si',
'@\]@si'
);
$replace_string = array ("<",
"bordercolor",
"border",
"bgcolor",
"cellpadding",
"cellspacing",
">"
);
$output = preg_replace($search_string, $replace_string, $txt);
Note: I had to change the order of the array items so that "bdc" would not be returned as "borderc" instead of "bordercolor" because "bd" was found first. Also, I had to escape the brackets.I think that if you used the same method for your replacements, it would be easier to accomplish your goal and easier to spot any bugs that you may have. Also, because this replaces what you know you will have instead of ignoring what you don't know you will have, it requires you to anticipate fewer posibilities in the end. Additionally, the array can be enlarged to allow for other replace requests as well. I like one size fits all functions and routines. Harder to set up I know but easier to request later.
I hope this helps some.

vujsa
Comment/Reply (w/o sign-up)