DOT NET regular expression app, is also indispensable in DOT NET development
Public class regularfun {
Public regularfun () {}
/// /// judge whether a number is integer /// summary> /// string param> /// returns> public static Bool isinteger (String StrnotintPattern = new regex ("[^ 0-9-]"); regex objintpattern = new regex ("^ - [0-9] $ | ^ [0-9] $" ); Return! ObjNotintPattern.ismatch (strnumber) &&bjintpattern.ismatch (strnumber);}
/// /// determines if only characters and numbers are composed /// summary> /// param> /// returns> public static Bool isalphanumeric (string stralphanumericpattern = new regex ("[^ a-za-z0-9]"); return! objalphanumericPattern.ismatch (strtocheck);} /// /// verify login name : You can only enter 5-20 strings that start with letters, numbers, "_", "." //// summary> /// param> // / returns> public static bool isregusername (string username) {regex objalphanumericPattern = new regex ("^ [a-za-z] {1} ([A-ZA-Z0-9] | [._] {4,19} $ "); return! ObjalphanumericPattern.ismatch (username);} /// /// check password: You can only enter 6-20 letters, numbers, underscores /// Summary> /// param> /// returns> public static bool ispassword (string password) {regex objalphanumericPattern = new regex (@ "^ (/ w) { 6, 20} $ "); return! ObjalphanumericPattern.ismatch (password);}
/// /// Check ordinary phone, fax number: " " start, in addition to the digital, "-" /// summary> /// param> /// returns> public static bool istelepone (string tel) {regex objalphanumericPattern = new regex (@ "^ [ ] {0,1} (/ d) {1,3} [ ]? ([-]? ((/ d) | []) {1, 12}) $ "); return! objalphanumericPattern.ismatch (tel);} /// /// check mobile number : Must start with the beginning, in addition to the numbers, can contain "-" /// summary> /// param> /// returns> public static bool Ismobil (String Mobile) {regex objalphanumericPattern = new regex (@ "^ [ ] {0,1} (/ d) {1,3} []? ([-]? (/ D) | []) { 1, 12}) $ "); return! ObjalphanumericPattern.ismatch (mobile);
/// /// Verify IP address /// summary> /// param> /// returns> public static bool isipaddress String ipaddr) {regex objalphanumericPattern = new regex (@ "^ [0-9.] {1, 20} $"); return! objalphanumericPattern.ismatch (ipaddr);}
}