<?php $strings = [ "12-blog/", "12-blog/blog2/", "en/12-blog/", "en/12-blog/blog2/" ]; $pattern = '~^(?:en/)?\d{1,3}-[^/]+/$~'; foreach ($strings as $str) { if (preg_match($pattern, $str)) { echo "Match for $str" . PHP_EOL; } else { echo "No match for $str" . PHP_EOL; } }
You have javascript disabled. You will not be able to edit any code.