i'd recommend URI::Find. of course you can do it with a
regex, but i wouldn't start to build one myself.
for examples just look at the docs: URI::Find
there's a section called Example, i'm sure you'll find what you need there...
if you really want to do it yourself, view the source...