• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • 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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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