在 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);

相关文章