Hi,
I'm trying to write a simple regex to encode spacial characters.
I want to find either a^ or o^ in a block of text, and replace them with â or ô.
I've tried this but it does not seem to work:
function checkAccent($text){
$pat[0] = "/^a\^$/";
$pat[1] = "/^o\^$/";
$rep[0] = "â";
$rep[1] = "ô";
echo preg_replace($pat, $rep, $text);
}
I also unsuccesfully tried
$pat[0] = "/^a\\^$/";
$pat[1] = "/^o\\^/$";
// and
$pat[0] = "/a\^/";
$pat[1] = "/o\^/";
// and
$pat[0] = "/a\\^/";
$pat[1] = "/o\\^/";
Anyone?
Thanks,
Mei