Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

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.
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

I think you can use \xnn where nn is the hexadecimal value of the char, or \unnnn where nnnn is the unicode value.
Avatar of hankknight

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;
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial