Regex Samples

using System.Text.RegularExpressions;

  • detect a URL: Regex urlregex = new Regex(@"(http:"/"/(["w.]+"/?)"S*)", RegexOptions.IgnoreCase|RegexOptions.Compiled);
    regex for Detecting urls
  • ^((ht|f)tp(s?))"://([0-9a-zA-Z"-]+".)+[a-zA-Z]{2,6}(":[0-9]+)?(/"S*)?$
  • ^(?((?http:"/"/)*(?(www|[^"-"n]*)*)(".)*(?[^"-"n]+)".(?[a-zA-Z]{2,3}[^>"n]*)))$
  • ^(?((?http:"/"/)*(?(www|[^"-"n]*)*)(".)*(?[^"-"n]+)".(?[a-zA-Z]{2,3}[^>"n]*)))$
  • ^[http://www.|www.]["S]+$
  • detect a Email: Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+"@[a-zA-Z_0-9.-]+"."w+)", RegexOptions.IgnoreCase|RegexOptions.Compiled);
  • 你可能感兴趣的:(sample)