Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Regex check Valid URL

by vinoth.ree (Monsignor)
on Aug 17, 2015 at 08:13 UTC ( [id://1138848]=note: print w/replies, xml ) Need Help??


in reply to Regex check Valid URL

I have already picked one that best suits my needs

If you already chosen the best one, what do you want to discuss more?

what is the URL you are trying to validate?

what is the best Regex you chosen?


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^2: Regex check Valid URL
by hankcoder (Scribe) on Aug 17, 2015 at 10:26 UTC

    vinoth.ree, the said regex may not serve you any good but it may serve someone else. Furthermore, as to my knowledge, there are too many variant of url to validate for just one single prefect regex. And I am not looking for perfect regex.

    The previous regex I tested which I found on public internet are not able to serve my requirement.

    ^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\ +/[\w\-]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w] ++\=[\w\-]+)*)$
    Test URL:<br> http://www.abc.com/test.pl?a=1234 http://www.abc.com/?a=1234

    The above regex failed on 2nd url which it should be valid as well. My current successful tested regex that works for my need are:

    # @stephenhay (38 chars) ^(https?|ftp)://[^\s/$.?#].[^\s]*$ # @imme_emosol (54 chars) (https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$

    There isn't a need to discuss further if you feel there isn't a need to.

    Perhaps this post should be in Meditations instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1138848]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found