$re = '/([^\/]+)\/?
/m';
$str = 'https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/diavel/diavel-1260
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard
https://www.ducati.com/es/es/motocicletas/hypermotard/hypermotard-950
https://www.ducati.com/es/es/motocicletas/monster/monster-1200
https://www.ducati.com/es/es/motocicletas/monster/monster-1200-25-anniversario
https://www.ducati.com/es/es/motocicletas/monster/monster-1200r
https://www.ducati.com/es/es/motocicletas/monster/monster-797
https://www.ducati.com/es/es/motocicletas/monster/monster-821
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-1260-enduro
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-950
https://www.ducati.com/es/es/motocicletas/multistrada/multistrada-enduro
https://www.ducati.com/es/es/motocicletas/panigale/1299-panigale-r-final-edition
https://www.ducati.com/es/es/motocicletas/panigale/959-panigale
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4
https://www.ducati.com/es/es/motocicletas/panigale/panigale-v4-r
https://www.ducati.com/es/es/motocicletas/supersport/supersport
https://www.ducati.com/es/es/motocicletas/xdiavel/xdiavel
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php