Last post Jul 02, 2012 06:16 PM by velayudham
Jan 24, 2012 06:37 AM|sadhwani.manish|LINK
I am using Regular expression validator for validating URL (of asp.net validators)
Here is the expression: http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
It works well for fully qualified URL, but doesnt work if we use URL without http or https
That is it validates: http://msn.com, http://www.msn.com but not validates
what i need is that in addition to current behaviour, it validates the url not having http specifying, that is it should validate
Jan 24, 2012 06:50 AM|kedarrkulkarni|LINK
hope this helps...
Jan 24, 2012 06:54 AM|sadhwani.manish|LINK
Thanks dear,I tried this, it worked well except in one condition, It validates "www.msn" too..
need to invlidate this form (www.msn), its working fine except this case.
Jan 24, 2012 07:01 AM|srinanthuram|LINK
try this code
This should work for most regex processors:
What this matches:
It's not terribly strict, but it matches all standard domain names (but might let slip through some invalid ones).
Also, next time, you might want to include the programming language or context, because regex processors vary greatly in feature support.
see this url
Jan 24, 2012 08:15 AM|sadhwani.manish|LINK
Its not working,
However in given URL the reqular expression written is working except for the case "www.msn", it validates this too
Jan 24, 2012 08:18 AM|ramiramilu|LINK
Search for some Regex in http://regexlib.com/
also try to use Expresso - a free regex tool - http://www.ultrapico.com/Expresso.htm where you can create and test your own regex...
Jan 24, 2012 08:29 AM|salman behera|LINK
This should work for most regex processors:/((?:https?\:\/\/|www\.)(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)/iWhat this matches:Anything that starts with http://, https://, or www.Followed by at least one or more valid domain characters (a-z, 0-9, or -)Matches without case sensitivity (/i)It does not enforce white space, so it will match this: blahwww.domain.com, and returnwww.domain.com If you want to enforce space, add \s to the beginning, but then you have to ensure that you add a space to the beginning of the string to match.The (?:) blocks are non-matching groups. They prevent those specific groups of characters from being assigned a number. They can be replaced with matching groups () if your regex processor has trouble. Group 1 is always the entire URL.It's not terribly strict, but it matches all standard domain names (but might let slip through some invalid ones).Also, next time, you might want to include the programming language or context, because regex processors vary greatly in feature support.
Jan 24, 2012 09:55 AM|sadhwani.manish|LINK
This expression doesnt validate any url :(
Jan 24, 2012 10:25 AM|srinanthuram|LINK
Please See this urls
Jan 24, 2012 10:47 AM|kedarrkulkarni|LINK
I think this would solve u r issue...
I developed this by little trial and error and covers u r scenario.... i am sure that the expression can be optimised... but would work for now...
Jan 24, 2012 10:51 AM|sadhwani.manish|LINK
Thanks Kedarrkulkarni, for your help, it covered previous case... but now its not working for "https://google.com" :(
Jan 24, 2012 11:18 AM|kedarrkulkarni|LINK
how about this
Jan 24, 2012 11:41 AM|eprovidere|LINK
It would probably be a good idea to keep the
's intact in order to preserve the sub-domain. A regex pattern like this:
would match a URL that is not prefixed by a protocol (
Apr 11, 2012 12:21 PM|faizan khatri|LINK
Hi Thanks for the Answer, What if we want to add query string in http as well
Apr 17, 2012 10:28 AM|getabhi9|LINK
Try this..I have applied this in one of my projects and its working there. This should work
Let me know if you face any problem.
Jul 02, 2012 06:16 PM|velayudham|LINK
when we are u using .com that time it working fine but that is not only web site ulr format for example ( .com, .in , .org , .ac.in ) like this lot of format is there ..so please post answer like all url validation supported ..