4images Forum & Community

General / Allgemeines => Programming => Topic started by: Sunny C. on December 14, 2010, 11:06:13 PM

Title: bbcode
Post by: Sunny C. on December 14, 2010, 11:06:13 PM
Hello this Code dont work for me:
$text = preg_replace("/\[shadow\][color=#(.*?)\](.*?)\[\/color\][\/shadow\]/si", "<span style=\"text-shadow: 2px 2px 5px #\\1;\">\\2</span>", $text);
$text = preg_replace("/\[color=#(.*?)\][shadow\](.*?)[\/shadow\]\[\/color\]/si", "<span style=\"text-shadow: 2px 2px 5px #\\1;\">\\2</span>", $text);
Error:
Quote
Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 52 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 357

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 52 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 358
I cantīt find the error!
Title: Re: bbcode
Post by: Jan-Lukas on December 15, 2010, 12:47:31 AM
statt " dieses ' im Netz wird das so angeboten
$text = preg_replace('/\

z.B

$text = preg_replace('/\[color=([[:alnum:]]{6}?).*\](.*?)\[\/color\]/', '<font color="#$1">$2</font>', $text);

Title: Re: bbcode
Post by: Sunny C. on December 15, 2010, 05:25:31 PM
Danke dir.
Das habe ich allerdings auch schon versucht.
Das Problem ist das ich zwei Bbcode Varianten auf einmal umwandeln will.
Ich werde das aber noch etwas austesten!
Title: Re: bbcode
Post by: V@no on December 15, 2010, 05:33:03 PM
$text = preg_replace("/\[shadow\]\[color=#[a-z0-9]+\](.*)\[\/color\]\[\/shadow\]/si", "<span style=\"text-shadow: 2px 2px 5px #\\1;\">\\2</span>", $text);
$text = preg_replace("/\[color=#[a-z0-9]+\]\[shadow\](.*)\[\/shadow\]\[\/color\]/si", "<span style=\"text-shadow: 2px 2px 5px #\\1;\">\\2</span>", $text);
Title: Re: bbcode
Post by: Sunny C. on December 15, 2010, 05:46:03 PM
Thank you Vano,
but the errors are still there!

Quote
Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 51 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 357

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 51 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 358

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 53 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 377

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 53 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 378
Title: Re: bbcode
Post by: V@no on December 15, 2010, 05:56:45 PM
updated above
Title: Re: bbcode
Post by: Sunny C. on December 15, 2010, 06:09:20 PM
Also does not help.
I have now tried many things, but it does not work.
However, it was previously shown more mistakes and now only two errors displayed.

Quote
Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 51 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 357

Warning: preg_replace() [function.preg-replace]: Compilation failed: missing terminating ] for character class at offset 51 in /www/htdocs/w00b2576/testumgebung/4images/bbcodev3/bbcodev3.php on line 358
Title: Re: bbcode
Post by: V@no on December 15, 2010, 06:36:20 PM
are you sure on lines 357 and 358 my code? I doubt it.
Title: Re: bbcode
Post by: Sunny C. on December 15, 2010, 07:08:36 PM
You were right.
The Bbcode now causes no errors, but my idea did not succeed.
Look at the screenshot.

The color code from Color Bbcode supposed to be used for the shadow.

<span style=\"text-shadow: 2px 2px 5px #COLOR-CODE-FROM-COLOR-BBCODE\">TEXT</span>
Title: Re: bbcode
Post by: V@no on December 15, 2010, 07:12:39 PM
looks like you need move these lines above all other preg_replace..so they would be replaced first, then the rest of your bbcode

the sequence at witch your text is being replace does matter ;)
Title: Re: bbcode
Post by: Sunny C. on December 15, 2010, 07:46:32 PM
I've already done. But then nothing displays.
That's all pretty complex!