2009年4月9日星期四

[PerlChina] Re: 请问在Perl中,正则表达式中的\1 、\2 、\3是什么意思

2009/4/9 xu zhou <redicaps@gmail.com>:
> 都可以用,区别发生在于需要插值的地方,$1是匹配成功后才定义的
>
> $text =~ /(var1)(.*?)$1/                ##不能正常工作,$1没有赋值
>
> $text =~ /(var1)(.*?)\1/                ##能正常工作,相当于 /(var1)(.*?)var1/
这个总结的好!应该都明白了
> 2009/4/9 hfahe <hfahe@163.com>
>>
>> 不一样 $1, $2是使用在正则外的 正则内必须使用\1, \2
>>
>> 祝好
>> ________________________________
>> hfahe
>> 2009-04-09
>> ________________________________
>> 发件人: xjdengz
>> 发送时间: 2009-04-09 19:22:02
>> 收件人: perlchina
>> 抄送:
>> 主题: [PerlChina] Re: 请问在Perl中,正则表达式中的\1 、\2 、\3是什么意思
>>
>> 2009/4/9 purl lamp <lamp.purl@gmail.com>:
>> > 正则匹配模式里面的第一个分组捕获()对应 \1
>> > 依此类推,看看 perldoc perlre 好了。
>> 嗯,也可以用$1, $2.....
>> > 2009/4/9 MrLiu <submox@gmail.com>
>> >>
>> >> 在Learn Perl 4th中没有这方面的介绍,5th中到是有,但没看明白
>> >>
>> >
>> >
>> > >
>> >
>>
>
>
>
> --
> Xu Zhou
> Tju->PMO->Where?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: