我有一句话:
$text = "word word, dr. word: a.sh. word ak word?!..";
特殊词是:“博士”。、“a.sh”和“ak”
这个 :
$text = "word word, dr. word: a.sh. word ak word?!..";
$split = preg_split("/[^\w] ([\s]+[^\w] |$)/", $text, -1, PREG_SPLIT_NO_EMPTY);
print_r($split);
正则表达式给了我这个:
Array (
[0] => word
[1] => word
[2] => dr
[3] => word
[4] => a.sh
[5] => word
[6] => a.k
[7] => word )
我需要
数组 (
[0] => word
[1] => word
[2] => dr. #<----- 点必须在这里,因为“dr.”是特殊词 [3] => word
[4] = > a.sh. #<----- 点必须在这里,因为“a.sh”是特殊词 [5] => 词
[6] => ak
[7] => 词)