Solved

Regex: replace ¬" with '

Posted on 2009-05-12
3
392 Views
Last Modified: 2012-05-06
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
Comment
Question by:hankknight
3 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 24367996
I think you can use \xnn where nn is the hexadecimal value of the char, or \unnnn where nnnn is the unicode value.
0
 
LVL 16

Author Comment

by:hankknight
ID: 24368102
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
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 24368693
$str = preg_replace('|\xe2\xac\x22|',"'",$str);
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Python Regex Problem 24 86
Wordpress Query 1 35
PHP and Soap 3 30
PHP loop not working 4 33
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now