1. Listed below are some regular expressions for judging value types
/^d $/ //Non-negative integer (positive integer 0)
/^[0-9]*[1-9][0-9]*$/ //Positive Integer
/^((-d )|(0 ))$/ //Non-positive integer (negative integer 0)
/^-[0-9]*[1-9][0-9] *$/ //Negative integer
/^-?d $/ //Integer
/^d (.d )?$/ //Non-negative floating point number (positive floating point number 0)
/^ (([0-9] .[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*.[0-9 ] )|([0-9]*[1-9][0-9]*))$/ //Positive floating point number
/^((-d (.d )?)|(0 (. 0 )?))$/ //Non-positive floating point number (negative floating point number 0)
/^(-(([0-9] .[0-9]*[1-9][0-9] *)|([0-9]*[1-9][0-9]*.[0-9] )|([0-9]*[1-9][0-9]*))) $/ //Negative floating point number
/^(-?d)(.d)?$/ //Floating point number
2. How to use it in the program
var r = /^[0-9]* [1-9][0-9]*$/ //Positive integer
r.test(str); //str is the character you want to judge and returns true or false
3. Test a regular function, which can be used to determine the js function of digital, character, date and email
function TestRgexp(re, s){ // Parameter description re is the regular expression and s is the character to be judged
return re.test(s)
}
4. Function application