Re: how to run regex calculation

demerphq <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CANgJU+X36o4jGhaC=whK0L=qxq29MR-bB4vibY9AyNDHeYO6Rw@mail.gmail.com>
Oh. Heh. I misunderstood the intent. I thought you wanted to match a
sequence of digits followed by a space followed by more digits followed by
a space followed by the first set of digits repeated 0 or more times
followed by the second set of digits. If you want multiplication then
Joseph He's original answer was correct.

Yves

On Thu, 9 Jan 2020, 09:40 Wesley Peng, <[email protected]> wrote:

> Hallo
>
> on 2020/1/9 16:35, demerphq wrote:
> > $str=~/(\d+)\s(\d+)\s(\1*\2)/
> >
> > $1 refers to the capture buffers from the last completed match, \1
> > inside of the pattern part of a regex refers to the capture buffer of
> > the currently matching regex.
>
> This doesn't work too.
>
> perl -Mstrict -le 'my $str = "2 3 6"; print "true" if
> $str=~/(\d+)\s(\d+)\s(\1*\2)/'
>
> nothing printed.
>
>
> Regards.
>
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.