I have a string "/test:n(0-2)/div/" which I want to split via Regex into an array with function preg_split(). The output should be like this:
output = {
[0]=>"test:n(0-2)"
[1]=>"div"
}
However it seems not to be that easy as I have thought it is. Here are my attempts: https://regex101.com/r/iP2lD8/1
$re = '/\/.*\//';
$str = '/test:n(0-2)/div/';
$subst = '';
$result = preg_replace($re, $subst, $str, 1);
echo "The result of the substitution is ".$result;
Full match 0-17:
/test:n(0-2)/div/
What am I doing wrong?