Php preg_match如果比赛结束后有什么东西,则不匹配/

Php preg_match如果比赛结束后有什么东西,则不匹配/,php,preg-match,Php,Preg Match,我试图对某些类型的URL使用preg\u match。如果/blog/之后没有任何内容,我只想进行匹配,因此/blog/foo应该不匹配 preg_match("/^(http:\/\/)?([^\/]+)?(\/blog\/)/i", 'http://example.com/blog/', $matches) 如果在/blog/之后没有任何内容,我如何使其仅匹配?只需在/blog/之后搜索字符串的结尾: (preg_match('%.*?/blog/$%', $subject) 只需在/b

我试图对某些类型的URL使用
preg\u match
。如果
/blog/
之后没有任何内容,我只想进行匹配,因此
/blog/foo
应该不匹配

preg_match("/^(http:\/\/)?([^\/]+)?(\/blog\/)/i", 'http://example.com/blog/', $matches)

如果在
/blog/
之后没有任何内容,我如何使其仅匹配?

只需在/blog/之后搜索字符串的结尾:

(preg_match('%.*?/blog/$%', $subject)

只需在/blog/之后搜索字符串的结尾:

(preg_match('%.*?/blog/$%', $subject)