在 PHP 5.2 中修剪 unicode 空格 [英] Trim unicode whitespace in PHP 5.2

查看:25
本文介绍了在 PHP 5.2 中修剪 unicode 空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修剪 string(6) " page",其中第一个空格是 0xc2a0 不间断空格?

How can I trim a string(6) " page", where the first whitespace is a 0xc2a0 non-breaking space?

我试过 trim()preg_match('/^s*(.*)s*$/u', $key, $m);.

另一个问题:我怎样才能可靠地复制这些字符?它们似乎被转换为正常"空间,这使得调试变得困难.

Another question: How can I reliably copy these characters? They seem to be converted to "normal" spaces, which makes it hard to debug.

推荐答案

preg_replace('/^[pZpC]+|[pZpC]+$/u','',$str);

这篇关于在 PHP 5.2 中修剪 unicode 空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆