Solved

Regex: replace ¬" with '

Posted on 2009-05-12
3
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

717 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