0

在一个字符串中,我试图用 preg_replace 删除括号内的所有内容,但我对非拉丁字符有一些问题。我试过了:

$text = '(Hàng Refurbished) sdfsdfsdfsd (Đen)';
$text = preg_replace('#\([A-Z0-9p{L}]+\)#i', '', $text);
$text = preg_replace('# $#','', $text);
echo $text;

但它不工作

请问有什么建议吗?

4

2 回答 2

1

使用u修饰符,在字符类中添加空格,unicode 属性为\p{L}

$text = preg_replace('#\([A-Z0-9\p{L} ]+\)#ui', '', $text);
//                            __^  __^   __^
于 2014-09-01T07:15:41.253 回答
0
\(.*?\)

使用它来删除所有 .

见演示。

http://regex101.com/r/rX0dM7/5

于 2014-09-01T07:20:12.043 回答