分享

Django正则表达式

 怎么了啊早上 2014-04-20

正则表达式

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./r/python/re-module/.

 

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

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

 Posted by  at 02:02 Tagged with: 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多