I have the path of a file and I want to extract parts of it with a regex. But the pattern seems to be wrong, it only gives me the last match.
$s = 'engine/plugins/renderer_smarty/plugins/css_minify/';
preg_match('@^engine/(plugins/(.+?)/)+$@i',$s,$matches);
Result:
array (3):
0 => string (50): "engine/plugins/renderer_smarty/plugins/css_minify/"
1 => string (19): "plugins/css_minify/"
2 => string (10): "css_minify"
Expected result:
array (5):
0 => string (50): "engine/plugins/renderer_smarty/plugins/css_minify/"
1 => string (24): "plugins/renderer_smarty/"
2 => string (15): "renderer_smarty"
3 => string (19): "plugins/css_minify/"
4 => string (10): "css_minify"
What's wrong in the pattern?
Thanks!
Aucun commentaire:
Enregistrer un commentaire