使用reg.exp检测URL

I am currently trying to build a router in a framework i'm doing.

Therefore I need to match the URL - e.g. "/blog/2006/21" with e.g. "/blog/:year/:is"

My problem is, that my reg.exp, that I am creating is accepting if the URL contains more, than I actually add to my reg.exp. I am using the preg_match function in PHP.

<?php
$var = '/blog/2006/21';

if(preg_match($var, '/blog\/([0-9]+)\/([0-9]+)/')){
    //do something
}
?>

I ONLY want it to match e.g. "/blog/2006/21/" - and not e.g. "/blog"/2006/21/some/more"

Am I doing it the wrong way - or is preg_match not the most suitable solution for this matter?

Thanks in advance, Dennis.

You can add $ at the end of you pattern which means "end-of-string"