當使用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