解决正则问题 1

来源:互联网 发布:photoshop8.0软件下载 编辑:程序博客网 时间:2024/06/12 13:17

解决正则问题 1


re.findall(r”([^=]+)=([^%s]+%s?|\Z)” % (re.escape(conf.paramDel or “”)

  1. re.escape() 什么意思,是干什么的?
    Escape all non-alphanumeric characters in pattern
    匹配所有的非数字,字母的结果(转义字符的功能)
In [14]: import reIn [15]: s="*&%&$%(&*("In [16]: t=re.escape(s)In [17]: print t\*\&\%\&\$\%\(\&\*\(----------re.findall()Type:        functionString form: <function findall at 0x7febc5aa9ed8>File:        /usr/lib/python2.7/re.pyDefinition:  re.findall(pattern, string, flags=0)Docstring:Return a list of all non-overlapping matches in the string.If one or more groups are present in the pattern, return alist of groups; this will be a list of tuples if the patternhas more than one group.Empty matches are included in the result.
0 0