Reputation: 1779
What would be the regular expression to find the substrings www.
and http://
in a domain name.
Basically I am writing an MVC validation to disallow a word that includes
www.
, http://
or http://www.
in it.
Upvotes: 1
Views: 355
Reputation: 25231
Try:
Regex.IsMatch(myString, @"(www\.|http://)");
If you want to specify that they aren't allowed at the start of the string, but allow them elsewhere, use:
Regex.IsMatch(myString, @"^(www\.|http://)");
Upvotes: 3