<?php
$string='先秦兩漢';
var_export(preg_split('~~u', $string, 0, PREG_SPLIT_NO_EMPTY));
echo "\n---\n";
var_export(preg_split('~\X\K~u', $string, 0, PREG_SPLIT_NO_EMPTY));
echo "\n---\n";
var_export(preg_split('~\X\K(?!$)~u', $string));
echo "\n---\n";
var_export(mb_split('\X\K(?!$)', $string));
echo "\n---\n";
var_export(preg_match_all('~\X~u', $string, $out) ? $out[0] : []);
- Output for 7.3.0 - 7.3.33, 8.1.28 - 8.1.31, 8.2.18 - 8.2.26, 8.3.5 - 8.3.14, 8.4.1 - 8.4.2
- array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
- Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
---
array (
0 => '先秦兩漢',
)
---
array (
0 => '先',
1 => '秦',
2 => '兩',
3 => '漢',
)
preferences:
86.02 ms | 409 KiB | 5 Q