Using System;
Namespace Regexlib {
////// Summary of Class1.
Public class Regexlib {
Public Regexlib (){
/// TODO: add the constructor logic here //
}
// Search for the input string and return all href = "..." Values
String DumpHrefs (String inputString ){
Regex r;
Match m;
R = new Regex ("hrefs * = 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}) (]?) $ ");
}
// The Date Format of dd-mm-yy replaces the date format of mm/dd/yy.
String MDYToDMY (String input ){
Return Regex. Replace (input, "B (? D {1, 2 })/(? D {1, 2 })/(? D {2, 4}) B "," $ {day}-$ {month}-$ {year }");
}
// Verify whether it is decimal
Bool IsValidDecimal (string strIn ){
Return Regex. IsMatch (strIn, @ "[0]. d {1, 2} | [1]");
}
// Verify whether the phone number is used
Bool IsValidTel (string strIn ){
Return Regex. IsMatch (strIn, @ "(d + -)? (D {4 }-? D {7} | d {3 }-? D {8} | ^ d {7, 8}) (-d + )? ");
}
// Verification year, month, and day
Bool IsValidDate (string strIn ){
Return Regex. IsMatch (strIn, @ "^ 2d {3 }-(? : 0? [1-9] | 1 [0-2])-(? : 0? [1-9] | [1-2] d | 3 [0-1]) (? : 0? [1-9] | 1d | 2 [0-3]) :(? : 0? [1-9] | [1-5] d ):(? : 0? [1-9] | [1-5] d) $ ");
}
// Verify the suffix
Bool IsValidPostfix (string strIn ){
Return Regex. IsMatch (strIn ,@".(? I: gif | jpg) $ ");
}
// Verify whether the character ranges from 4 to 12
Bool IsValidByte (string strIn ){
Return Regex. IsMatch (strIn, @ "^ [a-z] {4, 12} $ ");
}
// Verify the IP address
Bool IsValidIp (string strIn ){
Return Regex. isMatch (strIn, @ "^ (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]). (d {1, 2} | 1dd | 2 [0-4] d | 25 [0-5]) $ ");
}
}
}