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. |