Using system;
Namespace regexlib {
// /// Class1's summary description.
PUBLIC CLASS regexlib {
Public regexlib () {
// // TODO: Add constructor logic here
}
/ / Search input strings and return all href = "..." values
String Dumphrefs (String InputString) {
Regex R;
Match m;
R = New Regex ("HREF // S * = // s * (?: /" (? <1> [^ / "] *) /" | (? <1> // s )) ",
Regexoptions.ignorecase | RegexOptions.comPiled;
FOR (M = R.Match (InputString);
M.success; m = m.nextmatch ()) {
Return ("Found Href" M.Groups [1]);
}
}
/ / Verify the email address
Bool isvalidemail (String Strin) {
// Return True if Strin is in Valid E-mail format.
Return Regex.ismatch (Strin, @ "^ ([/ w - /.] ) @ (/ [[0-9] {1,3} /. [0-9] {1,3} /. 0-9] {1,3} /.) | ([/ W -] /.) )) ([A-ZA-Z] {2, 4} | [0-9] {1,3 }) (/]?) $ ");
}
// DD-MM-YY date is in place of the date form of MM / DD / YY.
String mDytodmy (string infut) {
Return Regex.replace (Input, "// b (?
// D {1, 2}) / (?
// D {1, 2}) / (?
// D {2,4} // b "" $ {day} - $ {month} - $ {year});
}
// Verify that it is a decimal
Bool isvaliddecimal (string strin) {
Return Regex.ismatch (Strin, @ "[0] ./ D {1, 2} | [1]");
}
/ / Verify that whether it is a phone number
Bool isvalidtel (String Strin) {
Return Regex.ismatch (Strin, @ "(/ D - -)? (/ d {4} -? / d {7} | / d {3} -? / d {8} | ^ / d {7,8} (- / d )? ");
}
// Verification Year and Moon
Bool isvaliddate (string strin) {
Return regex.ismatch (strin, @ "^ 2 / d {3} - (?: 0? [1-9] | 1 [0-2]) - (?: 0? [1-9] | [1- 2] / d | 3 [0-1]) (?: 0? [1-9] | 1 / d | 2 [0-3]) :( ?: 0? [1-9] | [1-5 ] / d) :( ?: 0? [1-9] | [1-5] / d) $ ");
}
// Verify the name of the suffix
Bool isvalidPostfix (String Strin) {
Return Regex.ismatch (STRIN, @ "/. (? i: gif | jpg) $");
}
// Verify that the character is between 4 and 12
Bool isvalidbyte (String Strin) {
Return Regex.ismatch (Strin, @ "^ [a-z] {4, 12} $");
}
// Verify IP
Bool isvalidip (String Strin) {
Return Regex.ismatch (Strin, @ "^ (/ d {1, 2} | 1 / d / d | 2 [0-4] / d | 25 [0-5]) /. (/ d {1, 2 } | 1 / d / d | 2 [0-4] / d | 25 [0-5]) /. (/ D {1, 2} | 1 / d / d | 2 [0-4] / d | 25 [0-5]) /. (/ D {1, 2} | 1 / d / d | 2 [0-4] / d | 25 [0-5]) $ ");}
}
}
Reprinted: http://dotnet.mblogger.cn/commansource/posts/383.aspx