[PerlChina] perl 正则表达式

张晓亮 alaboszhang at gmail.com
Fri Jul 4 20:34:22 PDT 2008


奇怪了, 我的就通不过了. 环境跟你的一样. 

我再试试. 



  ----- Original Message ----- 
  From: fengpxu fengpxu 
  To: china-pm at pm.org 
  Sent: Saturday, July 05, 2008 11:06 AM
  Subject: Re: [PerlChina] perl 正则表达式


  my $str = '/Book/LN/16.aspx古典仙侠';

  print $1,$2 if $str =~/\/Book\/LN\/(\d+).aspx(.*)/;

  print 'ok';

  16古典仙侠ok

  windows xp sp2 perl 5.8.8 通过。


  2008/7/5 张晓亮 <alaboszhang at gmail.com>:

    各位:

        有类似如下字符串:
        Book/LN/16.aspx古典仙侠

        
        用:  
        print $1 if $str =~/\/Book\/LN\/(\d+).aspx/;

        这样可以得到  16


        用:
        print $1,$2 if $str =~/\/Book\/LN\/(\d+).aspx(.*)/;

        这样不能得到 $2
        
       请问这个正则该如何修改?



    aj



        

    _______________________________________________
    China-pm mailing list
    China-pm at pm.org
    http://mail.pm.org/mailman/listinfo/china-pm





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


  _______________________________________________
  China-pm mailing list
  China-pm at pm.org
  http://mail.pm.org/mailman/listinfo/china-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20080705/4b9bab19/attachment.html>


More information about the China-pm mailing list