后,我发现这个代码将匹配最多300个字符,然后在下一个最近的字中断:分割字符串一些字符用的preg_match
$var = 'This is a test text 1234567890 test check12.' # 44 chars
preg_match('/^.{0,300}(?:.*?)\b/iu', $var, $matches);
echo $matches[0];
44比300更低,所以我希望输出与$ var一样。
但输出是:
This is a test text 1234567890 test check12 # 43 chars
$比赛[0]不给我末点,但是是$ var一样。任何人都可以告诉我如何获得完整的字符串(带点)?
'*'表示0或更多。 '+'表示1个或更多。 – thetaiko 2010-02-24 14:10:23