Django正则表达式

正则表达式

Regular expressions (or regexes ) are a compact way of specifying patterns in text. While Django URLconfs allow arbitrary regexes for powerful URL-matching capability, youll probably use only a few regex patterns in practice. Heres a small selection of common patterns:

正则表达式 (或 regexes ) 是通用的文本模式匹配的方法。Django URLconfs 允许你 使用任意的正则表达式来做强有力的URL映射,不过通常你实际上可能只需要使用很少的一 部分功能。下面就是一些常用通用模式:

Symbol Matches
. (dot) Any character
\d Any digit
[A-Z] Any character, A-Z (uppercase)
[a-z] Any character, a-z (lowercase)
[A-Za-z] Any character, a-z (case insensitive)
+ One or more of the previous expression (e.g., \d+ matches one or more digit)
[^/]+ All characters except forward slash
? Zero or more of the previous expression (e.g., \d* matches zero or more digits)
{1,3} Between one and three (inclusive) of the previous expression
符号 匹配
. (dot) 任意字符
\d 任意数字
[A-Z] 任意字符, A-Z (大写)
[a-z] 任意字符, a-z (小写)
[A-Za-z] 任意字符, a-z (不区分大小写)
+ 匹配一个或更多 (例如, \d+ 匹配一个或 多个数字字符)
[^/]+ 不是/的任意字符
* 匹配0个或更多 (例如, \d* 匹配0个 或更多数字字符)
{1,3} 匹配1个到3个(包含)

For more on regular expressions, see http://www.djangoproject.com/r/python/re-module/.

 

有关正则表达式的更多内容,请访问 http://www.djangoproject.com/r/python/re-module/.

通过.http://djangobook.py3k.cn/chapter03/ecn/

 Posted by  at 02:02  Tagged with: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值