我如何在PHP中使用regex制作这个
http://www.domain.com/path/to/image/ipsum_image.jpg
匹配此项并忽略尺寸部分
http://www.domain.com/path/to/image/ipsum_image-300x200.jpg
请记住,300x200可以是任何东西,从4charsx4chars到1charx1chars
$subject = 'http://www.domain.com/path/to/image/ipsum_image-300x200.jpg';
$result = preg_replace('&(-[0-9]{1,4}x[0-9]{1,4})&is', '', $subject);
echo $result;
$str= "http://www.domain.com/path/to/image/ipsum_image-300x200.jpg";
$regex= '/('d{1,4})x('d{1,4}).jpg$/i';
preg_match($regex, $str, $match, PREG_OFFSET_CAPTURE, 3);
print_r($match);