Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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#

share|improve this question
    
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
add comment

1 Answer

up vote 0 down vote accepted

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;
        }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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