PHP preg_match将卷曲撇号与其他类型的卷曲引号不匹配。如何避免?
我有以下可变内容:PHP preg_match将卷曲撇号与其他类型的卷曲引号不匹配。如何避免?,php,regex,unicode,Php,Regex,Unicode,我有以下可变内容: $content\u content='“我做不到,她说。” 我想对其中的每个“单词”进行preg_匹配,包括收缩,所以我使用preg_匹配,如下所示: if (preg_match_all('/([a-zA-Z0-9’]+)/', $content_content, $matches)) { echo '<pre>'; print_r($matches); echo '</pre>'; } 我怎么能包括'而不包括'和'
$content\u content='“我做不到,她说。”代码>
我想对其中的每个“单词”进行preg_匹配,包括收缩,所以我使用preg_匹配,如下所示:
if (preg_match_all('/([a-zA-Z0-9’]+)/', $content_content, $matches))
{
echo '<pre>';
print_r($matches);
echo '</pre>';
}
我怎么能包括'而不包括'和'?这是因为您在字符集中使用的“奇特”撇号是以二进制形式处理的;您需要使用相应的Unicode模式启用Unicode模式:
Array
(
[0] => Array
(
[0] => ��
[1] => I
[2] => can’t
[3] => do
[4] => it
[5] => she
[6] => said
[7] => ��
)
[1] => Array
(
[0] => ��
[1] => I
[2] => can’t
[3] => do
[4] => it
[5] => she
[6] => said
[7] => ��
)
)
preg_match_all('/([a-zA-Z0-9’]+)/u', $content_content, $matches)