[SP-pm] Contando caracteres em regexp

Alexei Znamensky russoz at gmail.com
Mon Jul 26 17:12:09 PDT 2010


Usando o modelo do Eden, com
$_="aaaaaa" #(6x a)

temos:
    perl -le'$_="aaaaaa";/a+/;print em +'

ou, -3 em versão perl 5.10
    perl -E'$_="aaaaaa";/a+/;say em +'

2010/7/26 Nuba Princigalli <nuba em fastmail.fm>

> 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
>
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>



-- 
Alexei Znamensky [russoz_gmail_com] [russoz.wordpress.com] [
www.flickr.com/photos/alexeiz]
«Only love / Can bring the rain / That makes you yearn to the sky»
-------------- Pr�xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20100726/9014725b/attachment-0001.html>


More information about the SaoPaulo-pm mailing list