Ok lets say I have a URL
example.com/hello/world/20111020 (with or without the trailing slash). What I would like to do is strip from the url the domain example.com.
I have created the following regular expression for URLs
^https?://(((0|([1-9][0-9]{0,1}))(\.(0|([1-9][0-9]{0,1}))){3})|([a-zA-Z]([a-zA-Z0-9$\-_@\.&+!*"\'\(\),]|(%[0-9a-fA-F][0-9a-fA-F]))*(\.([a-zA-Z]([a-zA-Z0-9$\-_@\.&+!*"\'\(\),]|(%[0-9a-fA-F][0-9a-fA-F]))*))*))(/|((/([a-zA-Z]([a-zA-Z0-9$\-_@\.&+!*"\'\(\),]|(%[0-9a-fA-F][0-9a-fA-F]))*))*))$
It has been written for MySql - I am sure with a bit of fiddling you can get it you work for your needs.
BTW - I took the idea from an RFC - The number escapes me at this moment