You know you have done too much work with regular expressions when you think "Hey, wait a second, that can't possibly work" and start trying to debug it in the Ruby console for 10 minutes prior to realizing "Oh, HN is italicizing it because of the asterixes it is silently stripping."
'&^(([^:/?#]+):)?(//([^/?#]))?([^?#])(\?([^#]))?(#(.))?&'
The above regular expression is meant to match URI's. Since almost anything can be a URI, the re also matches almost everything.