当使用preg_split
分割字符串时,下面的代码不保留分隔符。分割字符串时保留分隔符
$feature_description = "- 1.Read/Write speed performance is based on internal testing.- 2.TBW (terabytes written) values calculated capacity.";
preg_split('/(- [0-9].)/',$feature_description,NULL,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
现在的产量为:
[0] => - 1.
[1] => Read/Write speed performance is based on internal testing.
[2] => - 2.
[3] => TBW (terabytes written) values calculated capacity.
但我想要的输出:
[1] => - 1.Read/Write speed performance is based on internal testing.
[2] => - 2.TBW (terabytes written) values calculated capacity.
它不是空的,这是直接链接:https://regex101.com/r/Dn0qLE/1 – anubhava