I have a string, I want to split it with the number delimiter, but I don't want the number itself to be an element of the array
I have this code which obviously doesn't work as I don't know how to do it
$string = "CARTON2BS3CT1APT";
$array = preg_split("/(,?\s+)|((?<=[a-z])(?=\d))|((?<=\d)(?=[a-z]))/i", $string );
Array
(
[0] => CARTON
[1] => 2
[2] => BS
[3] => 3
[4] => CT
[5] => 1
[6] => APT
)
In this specific case I would like to be able to achieve this:
array {
[0] => "CARTON",
[1] => "2BS",
[2] => "3CT",
[3] => "1APT"
}
You could do the following:
ej: [sep]
)Example:
PS: In my example I don't use your pattern because with it the expected result is not achieved. Regardless of the pattern, the idea is the same.