简体   繁体   English

php的Unicode正则表达式

[英]php regular expression for unicode

I have some text where unicode is written as text like this 我有一些文本,其中unicode是这样写的

There areu25ba 2 boys.

it should be like this 它应该是这样的

There are&#x25ba 2 boys.

Replace 'u' with '&#x' if there is unicode character. 如果存在Unicode字符,则将“ u”替换为“&#x”。

Thanks in advance 提前致谢

A naive way would be: 天真的方法是:

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

But I doubt 'udaff' would appreciate it. 但是我怀疑“乌达夫”会感激它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM