Using system;
Using system. Text. regularexpressions;
Namespace bobobomousecom. CRM
{
/// <Summary>
/// Summary of regexlib.
/// </Summary>
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 ("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}) (\]?) $ ");
}
// 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, @ "^ 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 suffix
Bool isvalidpostfix (string strin)
{
Return RegEx. ismatch (strin ,@"\.(? I: GIF | JPG) $ ");
}
// Verify whether the characters are between 4 and 12
Bool isvalidbyte (string strin)
{
Return RegEx. ismatch (strin, @ "^ [A-Z] {4, 12} $ ");
}
// verify the IP address
bool isvalidip (string strin)
{< br> 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]) $ ");
}< BR >}