0
Hello, in my code I want to separate a string, having as separator a value that should be found via regular expression. Down with what I tried:
$data = "Amazing.Stories.2020.S01E03.REPACK.720p.WEB.H264-GHOSTS.mkv";
$pattern = "[#^S\d\dE\d\d$#i]";
$d = preg_split($pattern, $data);
echo "<pre>";
print_r($d);
echo "</pre>";
In case the separator should be "S01E03", but is not able to find. the result that is giving is :
Array
(
[0] => Amazing.Stories.2020.S01E03.REPACK.720p.WEB.H264-GHOSTS.mkv
)
The desired result would be:
Array
(
[0] => Amazing.Stories.2020
[1] => REPACK.720p.WEB.H264-GHOSTS.mkv
)
I confess that I am bad with regular expressions, but this same Pattern finds when I use it in a preg_grep for example.
Where am I going wrong?
I reversed the issue because by changing the question you end up invalidating the answer, and the idea of the site is to have a question by specific problem. If you have another question (even if it is related), please ask another question (not forgetting to search before if there is already something on the site, of course)
– hkotsubo
And if the answer below has solved the split question, you can accept it, see here how and why to do it. It is not mandatory, but it is a good practice of the site, to indicate to future visitors that it solved the problem.
– hkotsubo
thanks again @hkotsubo. Your reply was of great value.
– Alexandre Baggott Ayres