3 回答
5
Try this:
$lines = preg_split('/(?<=[。!?])(?![。!?])/u',$body);
It splits at a position that's preceded by one of your delimiter characters but not followed by one. It doesn't consume the delimiter, and if there are two or more consecutive delimiters, it only matches after the last one.
于 2010-08-09T07:48:43.927 回答
0
In this case, you'd like to write the string splitter yourself. And keep continuous delimiters as a whole. (you can set a state variable indicating whether it is in text block or delimiter block).
于 2010-08-09T07:17:48.260 回答
0
You should use preg_match_all
instead of preg_split
, i.e.
preg_match_all("/[^?!。]+[?!。]+/u", $text, $res);
See http://www.ideone.com/rN7MB for usage.
于 2010-08-09T07:18:04.463 回答