我有以下变量内容:
$content_content = '“I can’t do it, she said.”';
我想为每个"单词"做一个preg_match,包括收缩,所以我使用preg_match如下:
if (preg_match_all('/([a-zA-Z0-9’]+)/', $content_content, $matches))
{
echo '<pre>';
print_r($matches);
echo '</pre>';
}
Run Code Online (Sandbox Code Playgroud)
但是,似乎通过在正则表达式中包含',它也会捕获卷曲的双引号,如上面的命令输出:
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] => …Run Code Online (Sandbox Code Playgroud)