Solved

Regex: replace ¬" with '

Posted on 2009-05-12
3
393 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 dynamically set the form action using jQuery.

943 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

6 Experts available now in Live!

Get 1:1 Help Now