Reputation: 13
How can I replace Å
with some other string using preg_replace?
Thanks!
Upvotes: 1
Views: 994
Reputation: 13
Thanks, guys!
I wanted to replace html entities from the 'content' field of a database table. I solved it by using the mysql REPLACE function. I didn't know it exists...
Thanks again!
Upvotes: 0
Reputation: 316979
In case your goal is to replace the Entity to it's character representation, you can also use
html_entity_decode
— Convert all HTML entities to their applicable charactersExample:
echo html_entity_decode('Å', ENT_COMPAT, 'UTF-8'); // echoes Å
Upvotes: 1
Reputation: 8382
I'm assuming PHP since you say preg_replace()
. You don't need to use regular expressions for this. You can simply use str_replace()
:
$string = str_replace('Å', 'something else', $string);
Regular expressions are overkill for simple replacement operations like this.
Upvotes: 5