Question:

  如何查看正则表达式模块re及其相关函数的意义

1、终端命令行下

python

>> import sys

>> sys.modules

###################################

一长串信息中字段modules对应的模块即为包含的模块。

###################################

>> import re

>> help(re)

Help on module re:

NAME
re - Support for regular expressions (RE). FILE
/usr/lib64/python2.7/re.py DESCRIPTION
This module provides regular expression matching operations similar to
those found in Perl. It supports both 8-bit and Unicode strings; both
the pattern and the strings being processed can contain null bytes and
characters outside the US ASCII range. Regular expressions can contain both special and ordinary characters.
Most ordinary characters, like "A", "a", or "0", are the simplest
regular expressions; they simply match themselves. You can
concatenate ordinary characters, so last matches the string 'last'. The special characters are:
"." Matches any character except a newline.
"^" Matches the start of the string.
"$" Matches the end of the string or just before the newline at
the end of the string.
"*" Matches 0 or more (greedy) repetitions of the preceding RE.
Greedy means that it will match as many repetitions as possible.
"+" Matches 1 or more (greedy) repetitions of the preceding RE.
"?" Matches 0 or 1 (greedy) of the preceding RE.
*?,+?,?? Non-greedy versions of the previous three special characters.
{m,n} Matches from m to n repetitions of the preceding RE.
{m,n}? Non-greedy version of the above.
"\\" Either escapes special characters or signals a special sequence.
[] Indicates a set of characters.
A "^" as the first character indicates a complementing set.
"|" A|B, creates an RE that will match either A or B.
(...) Matches the RE inside the parentheses.
The contents can be retrieved or matched later in the string.
(?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below).
(?:...) Non-grouping version of regular parentheses.
(?P<name>...) The substring matched by the group is accessible by name.
(?P=name) Matches the text matched earlier by the group named name.
(?#...) A comment; ignored.
(?=...) Matches if ... matches next, but doesn't consume the string.
(?!...) Matches if ... doesn't match next.
(?<=...) Matches if preceded by ... (must be fixed length).
(?<!...) Matches if not preceded by ... (must be fixed length).
(?(id/name)yes|no) Matches yes pattern if the group with id/name matched,
the (optional) no pattern otherwise.

>>> help(re.compile)

Help on function compile in module re:

compile(pattern, flags=0)
Compile a regular expression pattern, returning a pattern object.
(END)

2、IDE环境下(待续……)

最新文章

  1. docker for mac 学习记录
  2. android layout布局属性
  3. python 延迟绑定
  4. 【助教】Java获取数据库数据展示
  5. Cookie测试工具小汇
  6. 使用xml方式定义补间动画
  7. 【转】 UIView如何管理它的子视图
  8. 一步一步学EF系列 【7、结合IOC ,Repository,UnitOfWork来完成框架的搭建】
  9. [C#] .Net Core 全局配置读取管理方法 ConfigurationManager
  10. @GeneratedValue源码解析
  11. win10蓝屏,windbg的使用
  12. pd16.5增加字段备注
  13. A1041. Be Unique
  14. ThinkPHP 3.2公共类库、应用类库ThinkPHP/Library讲解
  15. day1_jmeter接口测试
  16. CentOS 建立本地yum源服务器
  17. hdu3294 manacher
  18. python开发之路Day17-算法设计(冒泡排序、选择排序、插入排序、二叉树)
  19. 【观点】“马云:金融是要为外行人服务&quot;,这个观点其实并不新鲜
  20. 「HNOI 2016」 序列

热门文章

  1. BZOJ 1022 [SHOI2008]小约翰的游戏John
  2. FFT多项式乘法加速
  3. BZOJ2442: [Usaco2011 Open]修剪草坪
  4. Object -C 数组 -- 笔记
  5. HUNNU--湖师大--11410--Eligibility
  6. UVa 340 Master-Mind Hints (优化查找&amp;复制数组)
  7. Java编程 的动态性,第 2部分: 引入反射--转载
  8. jquery跳出当前的each循环
  9. HDU 5139数据离线处理
  10. VideoView 视频播放 示例