In Visual Studio, their default Internet URL regular expression ... ...does not account for tildes. I believe the following will work... Does that look right?
The best idea, (well what i always do), is i make a file or a script or a program, which lets me test my expression. And i change it, when the program/script doesn't display the correct thing i was looking for. You will be amazed at how many mistakes you make.
Depending on what language you're using I would just try to find a library that is already doing it for you. Why re-invent the wheel. In Java, I just try to create URL object and see if it throws an exception. For Perl, there's Regexp::Common. In PHP, parse_url helps, but I don't think it's considered a true validator. Off the top of my head, it looks like the expression is missing ",:+#;@$". I'm probably missing other stuff too. Not sure about !^()<>'"\ for example.