I'm trying to rename some files using Regular Expression, but I'm stuck in a specific format. I have video files in this format:
Yu.Yu.Hakusho Ep.001 - The Death
I need to format using regex for:
Yu.Yu.Hakusho.S01E01 - The Death
I've tried using ([^ ]+)*.(\w{0,2}).([0-9]+)*.(.*.)
to capture only what I need and format, as can be seen below:
$texto = "Yu.Yu.Hakusho Ep.001 - A Morte";
$regex = "/([^ ]+)*.(\w{0,2}).([0-9]+)(.*.)/";
preg_match($regex,$texto,$m);
echo $m[1].".S01E".$m[3].$m[4];
And the output is
Yu.Yu.Hakusho.S01E001 - The Death
I'm not sure how to leave the string 001
with only the last two digits.
How do I do this with regex? (I can not use replace, I need to do only with ER myself)
Note: I used php as an example, but I need to apply a regex, independent of language, as can be seen here in this link: link