---
title: "数字的正则表达式"
author: "beyondsanli"
date: "2009-03-21T17:12:07Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2009-03-21T17:12:07Z"
id: 352804
url: "https://beyondsanli.iteye.com/blog/352804"
---

(\\d{3}-|\\d{4}-)?(\\d{8}|\\d{7})?       //国内电话    
  ^\[1-9]\*\[1-9]\[0-9]\*$         //腾讯QQ    
  ^\[\\\\w-]+(\\\\.\[\\\\w-]+)\*@\[\\\\w-]+(\\\\.\[\\\\w-]+)+$　　　　//email地址      
  ^\[a-zA-z]+://(\\\\w+(-\\\\w+)\*)(\\\\.(\\\\w+(-\\\\w+)\*))\*(\\\\?\\\\S\*)?$　　//url    
  ^\\d+$　                 　//非负整数      
  ^\[0-9]\*\[1-9]\[0-9]\*$　　//正整数      
  ^((-\\\\d+)|(0+))$　　//非正整数    
  ^-\[0-9]\*\[1-9]\[0-9]\*$　　//负整数      
  ^-?\\\\d+$　　　       　//整数      
  ^\\\\d+(\\\\.\\\\d+)?$　　//非负浮点数    
  ^((\[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-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个英文字母或者下划线组成的字符串