quick answer, modified Arun's answer to accept '/page', '/page/subpage', 'page/subpage'
/(\/?[\w-]+)(\/[\w-]+)*\/?|(((http|ftp|https):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?)/gi
but in actually, validate the url with RegExp is never esay. lots of edge case, like './page', '../page' etc.
analyse your requirement carefully, write down the major test cases, write a RegExp pass them all. and be careful with performance.