Specific use can refer to: http://blog.csdn.net/tsinfeng/archive/2010/07/16/5739366.aspx
Public bool isint (string Str)
{
// ^ ([+-]?) Indicates that the addition/subtraction sign can only appear at the beginning of a string and has only one
/// D * indicates that there can be multiple or one decimal number.
// $ Indicates the end of the string
Return RegEx. ismatch (STR, @ "^ ([+-]?) /D * $ "); // returns an integer that can only begin with a positive or negative number.
}
Public bool isunint (string Str)
{
// ^ ([+-]?) Indicates that the addition/subtraction sign can only appear at the beginning of a string and has only one
/// D * indicates that there can be multiple or one decimal number.
// $ Indicates the end of the string
Return RegEx. ismatch (STR, @ "^/D * $"); // returns an integer.
}
Public bool isemail (string Str)
{
// The Mail format is string @ string. String (the last string must be 1 to 3 characters)
Return RegEx. ismatch (STR, @ "^ ([/W] *) ([@]?) ([/W] *) ([.]?) ([/W] {1, 3}) $ ");
}
Public bool checkfloat (string svalue)
{
// Check whether the value is a floating point number with 5 decimal places
Return RegEx. ismatch (svalue, @ "^ (/D *) ([.] {0, 1}) (/d {0, 5}) $ ");
}
Public bool isnumeric (string Str)
{
// Determines whether it is a numeric value with a decimal point
Return RegEx. ismatch (STR, @ "^ ([+-]?) /D * [.]? /D * $ ");
}
Public 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}) (/]?) $ ");
}
Public static bool checkstring (string svalue)
{
If (RegEx. ismatch (svalue, @ "^ ([0-9] {1 ,})(. *) ([0-9] {1,}) $ "))
{
// If the expression starts with a number
// Check whether the matching operator is addition, subtraction, multiplication, and division. If not, the return result is true.
If (RegEx. ismatch (svalue,
@ "([0-9] {1,}) ([/+/-/*/] {2 ,}) ([0-9] {1,}) | ([0-9] {1 ,}) ([^/+/-/* //] {1,}) ([0-9] {1 ,}))"))
{
// The expression is invalid.
Return false;
}
Else
{
Return true;
}
}
Else
{
Return false;
}
}