• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

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.
0
hankknight
Asked:
hankknight
1 Solution
 
Todd GerbertIT ConsultantCommented:
I think you can use \xnn where nn is the hexadecimal value of the char, or \unnnn where nnnn is the unicode value.
0
 
hankknightAuthor Commented:
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

0
 
amit_gCommented:
$str = preg_replace('|\xe2\xac\x22|',"'",$str);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now