17個の一般的な正規表現

1575 ワード

"^\\d+$"    //    (    + 0)

"^[0-9]*[1-9][0-9]*$"    //   

"^((-\\d+)|(0+))$"    //    (    + 0)

"^-[0-9]*[1-9][0-9]*$"    //   

"^-?\\d+$"    //  

"^\\d+(\\.\\d+)?$"    //     (     + 0)

"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"    //    

"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"    //     (     + 0)

"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //    

"^(-?\\d+)(\\.\\d+)?$"    //   

"^[A-Za-z]+$"    // 26           

"^[A-Z]+$"    // 26              

"^[a-z]+$"    // 26              

"^[A-Za-z0-9]+$"    //    26           

"^\\w+$"    //   、26                

"^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$"    //email  

"^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$"    //url  
//      
<script language="JavaScript" type="text/javascript">
function checkNum(obj)
{
 var re = /^-?[1-9]*(\.\d*)?$|^-?d^(\.\d*)?$/;
     if (!re.test(obj.value))
    {
if(isNaN(obj.value)){        alert("    ");
		obj.value="";
        obj.focus();
        return false;}

     }
}  
</script>