Page 1 of 1

Preg_Replace with Special Characters not working

Posted: Sat Feb 16, 2008 12:43 am
by tecktalkcm0391
I cant get the preg_replace to match [#A] where a can be any letter, uppercase or lowercase to replace with <a name=""></a>

Re: Preg_Replace with Special Characters not working

Posted: Sat Feb 16, 2008 12:59 am
by tecktalkcm0391
using this now...

Code: Select all

<?php 
$str = "[#A]Bah blah blah ba[#B]";
echo preg_replace("/\[\#[(A-z)]\]/", '<a name="#$0"></a>', $str);
?>
 
but not getting excatly what i want, and how I can figure out how about getting it.... the above returns

<a name="#[#A]"></a> instead of <a name="#A"></a>... how can i fix that?