正则

1.关于数字

^

d{1,3} 匹配指定数字位数1-3

d{n}匹配位数

d+ 匹配全整数

[12-15]$  匹配数字范围

11[1-9]{1,1}

[0-1]d|2[0-4]  表达两位数字 00-24  修正[0-9]|[1][0-2]d[0-4]{1}  

[1-9]d{0,2} 表达1-999

 8000-19999 即是 把范围拆开8000-9999和10000-19999 然后用|拼凑起来:

^[8-9]{1}[0-9]{3}$|^1[0-9]{4}$

{} 表达位数

 通过python检查正则:

#coding:utf8
import re
import sys
i=0
for x in range(0,10000,1):
	x=str(x)
	if len(re.findall(r"^[0-5][0-9]{3}$",x))>0:
		i+=1
		print re.findall(r"^[0-5][0-9]{3}$",x)[0]+'-------------------------'+str(i)+'-------------------------'+str(x)

  

参考:http://lippeng.iteye.com/blog/1038986

2018-01-24

对于神箭手云中 正则时不要添加^,否则无法识别

原文地址:https://www.cnblogs.com/crac/p/6642111.html