http://qs1969.pair.com?node_id=864102

japhy has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to solve the following problem with a regex, and so far I have not been successful. I've mostly resigned myself to solving it without a regex, but I'd like to know if anyone here can come up with a clever solution.

I have a potentially malformed URL. It MAY be missing some of the leading characters of the "http://". That is, it might be tp://www.foo.com/ or ://www.foo.com; then again, it might be fine.

I am trying to determine WHAT I need to supply to the beginning of it. I know I could just do a check for ^http://, ^ttp://, ^tp://, and so on, but that seems so barbaric. Any ideas?


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
Nos autem praedicamus Christum crucifixum (1 Cor. 1:23) - The Cross Reference (My Blog)