The user should be able to write it in any of the below formats
http://www.microsoft.com
or
https://www.microsoft.com
or
http://www.microsoft.com
Programming Language : C#
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should work for most regex processors:
What this matches:
http://,https://, orwww./i)blahwww.domain.com, and returnwww.domain.comIf you want to enforce space, add\sto 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.