Examples of regular expressions used in script, but without saying how these regular expressions are used, now give you a few examples that you can look at.
Use regular expressions to determine if the Arabic numerals are 0-9
function Regisdigit (fData)
{
var reg = new RegExp ("^[0-9]$");
Return (Reg.test (fData));
}
Use this expression to get the length of the string
function Regdatalength (fData)
{
var vallength = fdata.length;
var reg = new RegExp ("^[\u0391-\uffe5]$");
var result = 0;
for (i=0; i< vallength; i++)
{
if (Reg.test (Fdata.charat (i)))
{
result + = 2;
}
Else
{
Result + +;
}
}
return result;
}
Apply extension to determine if the value is numeric
function Regisnumber (fData)
{
var reg = new RegExp ("^[-]?[ 0-9]+[\.]? [0-9]+$ ");
Return Reg.test (FData)
}
Verify email is correct
function Regisemail (fData)
{
var reg = new RegExp ("^[0-9a-za-z][email protected][0-9a-za-z]+[\.") {1} [0-9a-za-z]+[\.]? [0-9a-za-z]+$ ");
Return Reg.test (FData);
}
Determine if the phone number is correct
function Regisphone (fData)
{
var reg =/^ (\+86)? (1[0-9]{10}) $/;
Return Reg.test (FData);
}
JS Regular Reprint