[PerlChina] perl 正则表达式

fengpxu fengpxu fengpxu at gmail.com
Fri Jul 4 20:06:42 PDT 2008


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20080705/c7fec08b/attachment.html>


More information about the China-pm mailing list