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


in reply to What is missing from the beginning of this string?

   I have a potentially malformed URL. It MAY be missing ... then again, it might be fine.

Honestly, I haven't the faintest clue what you're trying to do or why you think there is a problem. Here's what I'm able to gather from your post:

  1. You have some source providing your script/program with URLs.
  2. Your script/program is acting on that information.
  3. Since your code is not always doing what is expected, you believe that there's a chance you're getting invalid URLs.

Sounds to me like it's time for debugging, which for me means to start adding print statements to figure out what's happening where. For example, print out the URLs, then look to see what kind of issues there are, and then develop a plan to deal with them. Doing this might help you figure out if you're getting invalid URLs and if so, how are they invalid, which in turn helps with figuring out the regex.

The only other idea right now is to find a module that does the URL validation for you.

Replies are listed 'Best First'.
Re^2: What is missing from the beginning of this string?
by japhy (Canon) on Oct 08, 2010 at 00:47 UTC
    "I haven't the faintest clue what you're trying to do"

    I am trying to correct a potentially malformed "http://" at the beginning of a URL.

    I am not in control of the URLs I am receiving. It is not for me to debug, it is simply for me to correct.


    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)
Re^2: What is missing from the beginning of this string?
by ambrus (Abbot) on Oct 09, 2010 at 09:22 UTC

    Haven't you ever copy-pasted urls with the mouse from a window to the browser title bar and find that you failed to select the h at the beginning?