[SP-pm] Contando caracteres em regexp

Nuba Princigalli nuba at fastmail.fm
Mon Jul 26 14:57:41 PDT 2010


OK. Aqui como fica com pos();

$a = "abcd";
$a =~ m/$/g; 
say pos($a);

On Mon, 26 Jul 2010 18:45 -0300, "Pinguim Azul" <bluepenguin em gmail.com>
wrote:
> length tem 6 letras, é muito comprido :)
> 
> 2010/7/26 Nuba Princigalli <nuba em fastmail.fm>:
> > voce pode casar com o final da string e consultar a posicao onde houve o
> > match
> > com http://perldoc.perl.org/functions/pos.html
> >
> > algum motivo em particular para nao usar o length?
> >
> > On Mon, 26 Jul 2010 18:11 -0300, "Pinguim Azul" <bluepenguin em gmail.com>
> > wrote:
> >> Tem algum jeito de contar os caracteres de uma regexp sem usar
> >> o length?
> >>
> >> Por exemplo:
> >>
> >> $_="aaaaaaaaaa";s/a+/length$&/e;print
> >>
> >> Isso retorna 10, mas eu queria uma versão sem o length, se possível.
> >>
> >> --
> >> Ricardo Bittencourt http://www.ricbit.com
> >> _______________________________________________
> >> SaoPaulo-pm mailing list SaoPaulo-pm em pm.org
> >> http://mail.pm.org/mailman/listinfo/saopaulo-pm
> >>
> > --
> > Nuba R. Princigalli  nuba em pauleira.com  http://pauleira.com  @nprincigalli
> > Discipline is not an end in itself, just a means to an end. - King Crimson
> >
> > _______________________________________________
> > SaoPaulo-pm mailing list
> > SaoPaulo-pm em pm.org
> > http://mail.pm.org/mailman/listinfo/saopaulo-pm
> >
> 
> 
> 
> -- 
> Ricardo Bittencourt
> http://www.ricbit.com
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
> 
--
Nuba R. Princigalli  nuba em pauleira.com  http://pauleira.com  @nprincigalli
Discipline is not an end in itself, just a means to an end. - King Crimson



More information about the SaoPaulo-pm mailing list