0

I am trying validate an input from a text box and I want to make sure it is a well formed SharePoint address, e.g. http://site/ Does anyone have a regular expression that can do this or another method of validating the input address?

Most the regex's I have found on the web validate normal website addresses, e.g. http://www.site.com which I don't want.

Edit: I am using C#

  • Are you doing this with JavaScript? – Christophe Sep 29 '11 at 21:39
  • I am writing this in C# – Meyer Denney Sep 29 '11 at 22:31
0

This isn't a regex, but it will check to see if its a valid uri which will get the job done. And I don't like regex's to begin with :)

        Uri uri = null;
        if (!Uri.TryCreate(siteCollectionURL, UriKind.Absolute, out uri) || null == uri)
        {
            //Invalid URL
            return false;
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.