Python论坛  - 讨论区

标题:[python-chinese] 一个关于正则表达式的问题

2007年07月23日 星期一 10:45

Richard achilles在vspecial.org
星期一 七月 23 10:45:27 HKT 2007

Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ


ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/84bd7012/attachment-0001.htm 

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

2007年07月23日 星期一 10:50

Tian askfor在gmail.com
星期一 七月 23 10:50:01 HKT 2007

¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý

On 7/23/07, Richard <achilles在vspecial.org> wrote:
>
>   <http://www.pythonbbs.cn/misc.php?action=viewratings&tid;=2247&pid;=2269>
> Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
>
> ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/1b9dc8f9/attachment.html 

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

2007年07月23日 星期一 11:01

beck917 beck917在gmail.com
星期一 七月 23 11:01:05 HKT 2007

split('/')[-2]
´óÌåÕâÑù£¬²»¹ýÓï·¨Ó¦¸Ã²»¶Ô¡£¡£¡£

ÔÚ07-7-23£¬Tian <askfor在gmail.com> дµÀ£º
>
> ¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý
>
> On 7/23/07, Richard <achilles在vspecial.org> wrote:
> >
> >  <http://www.pythonbbs.cn/misc.php?action=viewratings&tid;=2247&pid;=2269>
> > Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
> >
> > ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/586cefc7/attachment.htm 

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

2007年07月23日 星期一 11:17

Richard achilles在vspecial.org
星期一 七月 23 11:17:09 HKT 2007

ÒòΪ²»ÖªµÀÇ°ÃæÓм¸¸ö'/',Ö¸¶¨'/'³öÏÖ´ÎÊýµÄ»°µÃµ¹×żÇÊý,split('/')[-2] ²»ÖªµÀÐв»ÐÐ.
  ----- Original Message ----- 
  From: beck917 
  To: python-chinese在lists.python.cn 
  Sent: Monday, July 23, 2007 11:01 AM
  Subject: Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ


  split('/')[-2]
  ´óÌåÕâÑù£¬²»¹ýÓï·¨Ó¦¸Ã²»¶Ô¡£¡£¡£


  ÔÚ07-7-23£¬Tian <askfor在gmail.com> дµÀ£º 
    ¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý


    On 7/23/07, Richard <achilles在vspecial.org > wrote: 
      Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ


      ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?

      _______________________________________________
      python-chinese
      Post: send python-chinese在lists.python.cn 
      Subscribe: send subscribe to python-chinese-request在lists.python.cn
      Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
      Detail Info: http://python.cn/mailman/listinfo/python-chinese 



    _______________________________________________
    python-chinese
    Post: send python-chinese在lists.python.cn 
    Subscribe: send subscribe to python-chinese-request在lists.python.cn
    Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
    Detail Info: http://python.cn/mailman/listinfo/python-chinese





------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese在lists.python.cn
  Subscribe: send subscribe to python-chinese-request在lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/4a0b2ba8/attachment.html 

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

2007年07月23日 星期一 11:23

Tian askfor在gmail.com
星期一 七月 23 11:23:16 HKT 2007

Èç¹ûÈ·¶¨Êǵ¹ÊýµÚ¶þ²ãÄÇÔÚҪƥÅäµÄÇ°ºó¼ÓÉÏ/¾ÍÐÐÁË

editplusÀïÊÔµÄ
²éÕÒ
.+/([^/]+)/.+
Ìæ»»\1

http://www.pythonbbs.cn/XYZ/XXX/abc => XXX

On 7/23/07, Richard <achilles在vspecial.org> wrote:
>
>  ÒòΪ²»ÖªµÀÇ°ÃæÓм¸¸ö'/',Ö¸¶¨'/'³öÏÖ´ÎÊýµÄ»°µÃµ¹×żÇÊý,split('/')[-2] ²»ÖªµÀÐв»ÐÐ.
>
>  ----- Original Message -----
> *From:* beck917 <beck917在gmail.com>
> *To:* python-chinese在lists.python.cn
> *Sent:* Monday, July 23, 2007 11:01 AM
> *Subject:* Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
>
>
> split('/')[-2]
> ´óÌåÕâÑù£¬²»¹ýÓï·¨Ó¦¸Ã²»¶Ô¡£¡£¡£
>
> ÔÚ07-7-23£¬Tian <askfor在gmail.com> дµÀ£º
> >
> > ¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý
> >
> > On 7/23/07, Richard <achilles在vspecial.org <achilles在vspecial.org+>>
> > wrote:
> > >
> > >  <http://www.pythonbbs.cn/misc.php?action=viewratings&tid;=2247&pid;=2269>
> > > Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
> > >
> > > ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > <python-chinese在lists.python.cn+>
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>  ------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/47497c03/attachment-0001.htm 

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

2007年07月23日 星期一 11:28

Tian askfor在gmail.com
星期一 七月 23 11:28:52 HKT 2007

µÃ¸ÄһϠӦ¸ÃÕâÑù
.+/([^/]+)/[^/]+

¸Õ²ÅÄǸöд·¨ºÃÏñÓÐÎÊÌâ¡£¡£µ«²»ÖªµÀÔõô½á¹ûÊǶԵÄ


On 7/23/07, Tian <askfor在gmail.com> wrote:
>
> Èç¹ûÈ·¶¨Êǵ¹ÊýµÚ¶þ²ãÄÇÔÚҪƥÅäµÄÇ°ºó¼ÓÉÏ/¾ÍÐÐÁË
>
> editplusÀïÊÔµÄ
> ²éÕÒ
> .+/([^/]+)/.+
> Ìæ»»\1
>
> http://www.pythonbbs.cn/XYZ/XXX/abc => XXX
>
>  On 7/23/07, Richard <achilles在vspecial.org> wrote:
> >
> >  ÒòΪ²»ÖªµÀÇ°ÃæÓм¸¸ö'/',Ö¸¶¨'/'³öÏÖ´ÎÊýµÄ»°µÃµ¹×żÇÊý,split('/')[-2] ²»ÖªµÀÐв»ÐÐ.
> >
> >  ----- Original Message -----
> > *From:* beck917 <beck917在gmail.com>
> > *To:* python-chinese在lists.python.cn
> > *Sent:* Monday, July 23, 2007 11:01 AM
> > *Subject:* Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
> >
> >
> > split('/')[-2]
> > ´óÌåÕâÑù£¬²»¹ýÓï·¨Ó¦¸Ã²»¶Ô¡£¡£¡£
> >
> > ÔÚ07-7-23£¬Tian <askfor在gmail.com> дµÀ£º
> > >
> > > ¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý
> > >
> > > On 7/23/07, Richard <achilles在vspecial.org <achilles在vspecial.org+>>
> > > wrote:
> > > >
> > > >  <http://www.pythonbbs.cn/misc.php?action=viewratings&tid;=2247&pid;=2269>
> > > > Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ
> > > >
> > > > ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?
> > > >
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > <python-chinese在lists.python.cn+>
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to
> > > > python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >  ------------------------------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/0ed61fe0/attachment.html 

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

2007年07月23日 星期一 11:54

limodou limodou在gmail.com
星期一 七月 23 11:54:45 HKT 2007

On 7/23/07, Richard <achilles在vspecial.org> wrote:
>
>
>
> 问个关于正则表达式的问题
>
>
> 例如 http://www.pythonbbs.cn/XYZ/XXX/abc 的连接,我想匹配/XXX/那一层
> ,正则表达式该怎么写?

r'^/XYZ/(?P\w+)/abc/$'

-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

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

2007年07月23日 星期一 13:49

Richard achilles在vspecial.org
星期一 七月 23 13:49:19 HKT 2007

¶÷£¬Êǵģ¬ÎÒÊÇÒªµÃµ½£Ø£Ø£Ø£®ÕæÊÇллÄãÁË£¬ÎÒÊÔÁ˺ó¤Ê±¼äÁË£®ÏÖÔÚºÃÁË£®
  ----- Original Message ----- 
  From: Tian 
  To: Richard 
  Sent: Monday, July 23, 2007 12:46 PM
  Subject: Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ


  >>> m = re.compile('.+/([^/]+)/[^/]+')
  >>> s = 'http://www.pythonbbs.cn/XYZ/XXX/abc'
  >>> m.findall(s)
  ['XXX']

  ÄãÒªµÄÊÇXXXÂð
   
  On 7/23/07, Richard <achilles在vspecial.org> wrote: 
    ºÃÏó»¹ÊDz»´ó¶Ô
      ----- Original Message ----- 
      From: Tian 
      To: Richard ; python-chinese在lists.python.cn 
      Sent: Monday, July 23, 2007 11:28 AM
      Subject: Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ

       
      µÃ¸ÄһϠӦ¸ÃÕâÑù
      .+/([^/]+)/[^/]+

      ¸Õ²ÅÄǸöд·¨ºÃÏñÓÐÎÊÌâ¡£¡£µ«²»ÖªµÀÔõô½á¹ûÊǶԵÄ

       
      On 7/23/07, Tian <askfor在gmail.com> wrote: 
        Èç¹ûÈ·¶¨Êǵ¹ÊýµÚ¶þ²ãÄÇÔÚҪƥÅäµÄÇ°ºó¼ÓÉÏ/¾ÍÐÐÁË

        editplusÀïÊÔµÄ
        ²éÕÒ
        .+/([^/]+)/.+
        Ìæ»»\1

        http://www.pythonbbs.cn/XYZ/XXX/abc => XXX
         
        On 7/23/07, Richard <achilles在vspecial.org > wrote: 
          ÒòΪ²»ÖªµÀÇ°ÃæÓм¸¸ö'/',Ö¸¶¨'/'³öÏÖ´ÎÊýµÄ»°µÃµ¹×żÇÊý,split('/')[-2] ²»ÖªµÀÐв»ÐÐ.
            ----- Original Message ----- 
            From: beck917 
            To: python-chinese在lists.python.cn 
            Sent: Monday, July 23, 2007 11:01 AM
            Subject: Re: [python-chinese] Ò»¸ö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ

             
            split('/')[-2]
            ´óÌåÕâÑù£¬²»¹ýÓï·¨Ó¦¸Ã²»¶Ô¡£¡£¡£


            ÔÚ07-7-23£¬Tian <askfor在gmail.com> дµÀ£º 
              ¿ÉÒÔÖ¸¶¨/³öÏֵĴÎÊý


              On 7/23/07, Richard <achilles在vspecial.org > wrote: 
                Îʸö¹ØÓÚÕýÔò±í´ïʽµÄÎÊÌâ


                ÀýÈç http://www.pythonbbs.cn/XYZ/XXX/abc µÄÁ¬½Ó,ÎÒÏëÆ¥Åä/XXX/ÄÇÒ»²ã ,ÕýÔò±í´ïʽ¸ÃÔõôд?

                _______________________________________________
                python-chinese
                Post: send python-chinese在lists.python.cn 
                Subscribe: send subscribe to python-chinese-request在lists.python.cn
                Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
                Detail Info: http://python.cn/mailman/listinfo/python-chinese 



              _______________________________________________
              python-chinese
              Post: send python-chinese在lists.python.cn 
              Subscribe: send subscribe to python-chinese-request在lists.python.cn 
              Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
              Detail Info: http://python.cn/mailman/listinfo/python-chinese





--------------------------------------------------------------------


            _______________________________________________
            python-chinese
            Post: send python-chinese在lists.python.cn 
            Subscribe: send subscribe to python-chinese-request在lists.python.cn
            Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
            Detail Info: http://python.cn/mailman/listinfo/python-chinese 






          _______________________________________________
          python-chinese
          Post: send python-chinese在lists.python.cn 
          Subscribe: send subscribe to python-chinese-request在lists.python.cn 
          Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
          Detail Info: http://python.cn/mailman/listinfo/python-chinese






-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070723/cf06f858/attachment.htm 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号