Well, regex is probably the best answer. Keep in mind that the more idiot proof you try to make this regex, the more likely it is that someone will become a better idiot and insert something invalid that slips though. That said... :-)

print eregi("^http[s]?://[[:alnum:][:punct:]]+",$url);

should get you started.

It's not perfect, it needs to exclude - from the hostname, and check for a slash on the end etc...

    Cheer mate, you're a star.

    Mark

      Write a Reply...