我试图用preg_match从以下URL中获取12345。文本和第一次出现之间的PHP preg_match -
$url = "http://www.somesite.com/directory/12345-this-is-the-rest-of-the-url.html";
$beg = "http://www.somesite.com/directory/";
$close = "\-";
preg_match("($beg(.*)$close)", $url, $matches);
我试过了多种组合。 *? \ b
有谁知道如何从preg_match中提取12345的URL吗?
谢谢,完美的作品! – Mark 2011-02-07 20:17:15