This question already has an answer here:
I'm not on a product page (custom module) and I have the URL of a product page. Is it possible to get the product ID from a URL?
I checked Mage::getUrl but that seem to generate URLs - I need it the other way round. Is there a possibility to do that? Via the rewrite table?