cheers guys, first time on that board, hope you'll be helpfull 🙂
I'm actually coding my personnal BB code parser, which works for the moment, but i'd like to optimize it a bit
I've got 3 methods for bold, underline and italic strings
private function convertBold() {
$this->str2parse = preg_replace("/\[b\](.*?)\[\/b\]/", "<span style=\"font-weight:bold;\">\\1</span>", $this->str2parse);
}
private function convertItalic() {
$this->str2parse = preg_replace("/\[i\](.*?)\[\/i\]/", "<span style=\"font-style:italic;\">\\1</span>", $this->str2parse);
}
private function convertUnderline() {
$this->str2parse = preg_replace("/\[u\](.*?)\[\/u\]/", "<span style=\"text-decoration:underline;\">\\1</span>", $this->str2parse);
}
It works, but i'd like to make only one method.
So i thought abouut the ereg
private function convertBasics() {
if (ereg("\[(u|i|b)\](.+)\[\/\\1\]", $this->str2parse, $to))
print_r($to);
}
I'll then take $to[0] make a switch to apply my CSS style on it.
But i just can't get my ereg to match a simple string like
without the
[b*]test[/b*]
I really wonder where the problem is.
Btw, i've tryed this regular expression in Kodos and it worked:rolleyes: