Re: how to run regex calculation

Joseph He <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAD16sHvqpm8a+XLaL-PWrnPjC2dstbz6=y372AgQs5NR65tagw@mail.gmail.com>
I think $str =~ /(\d+)\s(\d+)\s(??{$1*$2})/   should do it
My Perl version is  v5.26.1

Joseph

On Wed, Jan 8, 2020 at 8:36 PM Wesley Peng <[email protected]> wrote:

> Hello
>
> Give the case I have a string,
>
> $str = "2 3 6";
>
> I want to match with:
>
> true if $str =~ /(\d+)\s(\d+)\s($1*$2)/;
>
> that's to say, the thrid column would be (firstCol * SecondCol).
>
> How to write regex for this?
>
> Thank you.
>
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.