cili
cili

Reputation: 13

Replace Å with something else

How can I replace Å with some other string using preg_replace? Thanks!

Upvotes: 1

Views: 994

Answers (3)

cili
cili

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

Gordon
Gordon

Reputation: 316979

In case your goal is to replace the Entity to it's character representation, you can also use

Example:

echo html_entity_decode('Å', ENT_COMPAT, 'UTF-8'); // echoes Å

Upvotes: 1

Daniel Egeberg
Daniel Egeberg

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

Related Questions