Novice
Novice

Reputation: 1011

php regular expression for unicode

I have some text where unicode is written as text like this

There areu25ba 2 boys.

it should be like this

There are&#x25ba 2 boys.

Replace 'u' with '&#x' if there is unicode character.

Thanks in advance

Upvotes: 0

Views: 324

Answers (1)

Wrikken
Wrikken

Reputation: 70490

A naive way would be:

preg_replace('/u([0-9a-fA-F]{4})/','&#x$1;',$string);

But I doubt 'udaff' would appreciate it.

Upvotes: 2

Related Questions