ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsValidUrl

Returns true when a string is a valid url

Source

public static class MyExtensionMethods {
        public static bool IsValidUrl(this string text) {
            Regex rx = new Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?");
            return rx.IsMatch(text);
        }
    }
}

Example

test
test
test

Author: unkown

Submitted on: 17 okt. 2007

Language: C#

Type: System.String

Views: 9728