Web Hosting Talk







View Full Version : PHP Help


PencWeb
09-03-2002, 04:21 PM
Why isn't this working? It's suppose to change in a string [ b ]text here[ / b ] (with no spaces, obviously) to <b>text here</b> but it doesn't do anything, no error :( Any help appreciated! :)

$message = preg_replace("#\[b\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/b\]#si", "<b>\\1</b>", $message);

thanks,
- Shawn

binasys
09-03-2002, 04:34 PM
$message = preg_replace("/\[b\](.+)\[\/b\]/siU", "<b>\\1</b>", $message);

That should work.

binasys
09-03-2002, 04:35 PM
Btw: I think your code isn't working due to you not escaping the / in the bit \[/b\]

PencWeb
09-03-2002, 08:49 PM
Thanks so much, I appreciate it ;)