Re: how to run regex calculation

demerphq <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CANgJU+VXVwC9E3FyEJC2-_SXDAgsPH3xbrrzSh=yP+fsryqMFw@mail.gmail.com>
My apologies you were right. I misunderstood the question. Yves

On Thu, 9 Jan 2020, 09:39 demerphq, <[email protected]> wrote:

> On Thu, 9 Jan 2020 at 05:49, Joseph He <[email protected]> wrote:
> >
> > I think $str =~ /(\d+)\s(\d+)\s(??{$1*$2})/   should do it
> > My Perl version is  v5.26.1
>
> I think you mean (??{ "$1*$2"}) which might work, but it will be error
> prone, (??{"(?$1)*$2") would be better, but both will be slow, as each
> time a new pattern willbe compiled.
>
> /(\d+)\s(\d+)\s(\1*\2)/
>
> just works, and does not recompile the pattern over and over. Look for
> "back references" in perlre.
>
> Yves
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.