perlquestion
japhy
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.
<p>
I have a potentially malformed URL. It MAY be missing some of the leading characters of the "http://". That is, it might be <c>tp://www.foo.com/</c> or <c>://www.foo.com</c>; then again, it might be fine.
<p>
I am trying to determine WHAT I need to supply to the beginning of it. I know I could just do a check for <c>^http://</c>, <c>^ttp://</c>, <c>^tp://</c>, and so on, but that seems so barbaric. Any ideas?
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-1936">
<hr/>
Jeff <tt><font color="#0000ff">[japhy]</font></tt> Pinyan,
[id://371157|P.L., P.M., P.O.D, X.S.]:
<a href="http://japhy.perlmonk.org/modules/">Perl</a>,
<a href="http://japhy.perlmonk.org/modules/Regexp-Parser/">regex</a>,
and <a href="http://lists.perl.org/showlist.cgi?name=perl5-porters"><tt>perl</tt></a>
<a href="http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=hacker">hacker</a>
<br>
<i>Nos autem praedicamus Christum crucifixum</i> (1 Cor. 1:23) - <b><a href="http://thecrossreference.blogspot.com/">The Cross Reference</a></b> (My Blog)
</div></div>