Preg_Replace with Special Characters not working
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Preg_Replace with Special Characters not working
I cant get the preg_replace to match [#A] where a can be any letter, uppercase or lowercase to replace with <a name=""></a>
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Re: Preg_Replace with Special Characters not working
using this now...
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?
Code: Select all
<?php
$str = "[#A]Bah blah blah ba[#B]";
echo preg_replace("/\[\#[(A-z)]\]/", '<a name="#$0"></a>', $str);
?>
<a name="#[#A]"></a> instead of <a name="#A"></a>... how can i fix that?