Python论坛  - 讨论区

标题:Re: [python-chinese] 关于正则表达式?

2006年06月26日 星期一 08:38

limodou limodou at gmail.com
Mon Jun 26 08:38:12 HKT 2006

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年06月26日 星期一 09:34

风向标 vaneoooo at gmail.com
Mon Jun 26 09:34:39 HKT 2006

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年06月26日 星期一 11:44

netkiller openunix at 163.com
Mon Jun 26 11:44:55 HKT 2006

好文章,解我燃煤之急.

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号