hankknight
asked on
Regex: replace ¬" with '
Using PHP I want to use regex to convert ¬" to ' (an apostrophe)
I don't want to use the actual characters â¬" in my regex because they could get corrupted by character set changes. Instead I need their numerical values.
I don't want to use the actual characters â¬" in my regex because they could get corrupted by character set changes. Instead I need their numerical values.
I think you can use \xnn where nn is the hexadecimal value of the char, or \unnnn where nnnn is the unicode value.
ASKER
How can I use the hexadecimal values with preg_replace?
<?php
$str='Replace this with an apostrophy: â¬" ';
$str = preg_replace('|\u00e2\u00e2\u2122|',"'",$str);
echo $str;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.