<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <script> var patt1=new RegExp("^[1-9][0-9]*$"); document.write(patt1.test("1000")); </script> </body> </html>
匹配非零整数,成功返回true,失败返回false。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <script> var patt1=new RegExp("^[1-9][0-9]*$"); document.write(patt1.test("1000")); </script> </body> </html>
匹配非零整数,成功返回true,失败返回false。