2006年06月26日 星期一 08:38
On 6/26/06, hobnail <hobnail at 163.com> wrote: > Python-chinese,您好! > > 在limodou的django的教程中有这样一个正则表达式:(?P\w+) 有点看不懂,请大侠指点一下! > (?P表示给匹配成功的一个名字,叫'fiilename' \w+表示一个或多个字符的序列。 括号括起来表示一个组。象?P 只能用在组里面。 详细的解释参见python库模块参考中的re模块。 -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit
2006年06月26日 星期一 09:34
http://wiki.woodpecker.org.cn/moin/RegExpInPython#head-2358765384844ed72f01658cbcde24613d941e9d 在06-6-26,limodou <limodou at gmail.com> 写道: > > On 6/26/06, hobnail <hobnail at 163.com> wrote: > > Python-chinese,您好! > > > > 在limodou的django的教程中有这样一个正则表达式:(?P\w+) 有点看不懂,请大侠指点一下! > > > > (?P表示给匹配成功的一个名字,叫'fiilename' > \w+表示一个或多个字符的序列。 > 括号括起来表示一个组。象?P只能用在组里面。 > > 详细的解释参见python库模块参考中的re模块。 > > -- > I like python! > My Blog: http://www.donews.net/limodou > My Django Site: http://www.djangocn.org > NewEdit Maillist: http://groups.google.com/group/NewEdit > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060626/00e3ae43/attachment.html
2006年06月26日 星期一 11:44
好文章,解我燃煤之急.
import re
lines = ['xover -100\r\n','xover 10-10\r\n','xover 10-','XOVER 10-100\r\n',
'mode ','mode reader\r\n','mode stream\r\n','mode case\r\n',
'group ','Group 10-10\r\n','GROUP cn.test\r\n','gRoUp cn.t1,cn.t2\r\n',
'list','list ','list active',
'newgroups aaa bbb gmt','newgroups 11','newgroups 060606 121212','newgroups 060606 121212 GMT',
'',''
]
command = (r'^mode [reader|stream]',
r'^list [active|active.times|newsgroups|subscriptions]',
r'^xover [0-9]+-[0-9]+',
r'^group .+',
r'^newgroups [0-9]+ [0-9]+ GMT'
)
#yymmdd hhmmss [GMT]
for com in command:
digs = re.compile(com,re.IGNORECASE)
for line in lines:
if digs.match(line):
print line,
----- Original Message -----
From: 风向标
To: python-chinese at lists.python.cn
Sent: Monday, June 26, 2006 9:34 AM
Subject: Re: [python-chinese] 关于正则表达式?
http://wiki.woodpecker.org.cn/moin/RegExpInPython#head-2358765384844ed72f01658cbcde24613d941e9d
在06-6-26,limodou <limodou at gmail.com> 写道:
On 6/26/06, hobnail <hobnail at 163.com> wrote:
> Python-chinese,您好!
>
> 在limodou的django的教程中有这样一个正则表达式:(?P\w+) 有点看不懂,请大侠指点一下!
>
(?P 表示给匹配成功的一个名字,叫'fiilename'
\w+表示一个或多个字符的序列。
括号括起来表示一个组。象?P 只能用在组里面。
详细的解释参见python库模块参考中的re模块。
--
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
------------------------------------------------------------------------------
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060626/7d0545af/attachment.html
Zeuux © 2025
京ICP备05028076号