[PerlChina] 请问如何统计字符串中某个条件出现的次数

Havel Zhang havel.zhang at gmail.com
Fri Aug 4 04:12:01 PDT 2006


呵呵,还有如下的方法:)

my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]';

my $i;
$i = split /=/,$a;

print $i-1;





On 8/4/06, 潘建锋 <panjianfeng1979 at gmail.com> wrote:
>
> 谢谢你了,没有专门的函数吗?
>
> 2006/8/4, fayland <fayland at gmail.com>:
>
> > 潘建锋 wrote:
> > > 比如:/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]
> > > 中"="出现的次数。
> > > 谢谢!
> >
> > my $a = '/sts3c_au4-j=[1..64]/vt2_tu12-k=[1..3]-l=[1..7]-m=[1..3]';
> >
> > my $i;
> > $i++ while ($a =~ /=/g);
> >
> > print $i;
> >
> > >
> > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > China-pm mailing list
> > > China-pm at pm.org
> > > http://mail.pm.org/mailman/listinfo/china-pm
> >
> >
> > --
> > Fayland Lam // http://www.fayland.org/
> >
> > _______________________________________________
> > 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/20060804/8a6dfe0e/attachment.html 


More information about the China-pm mailing list