if regex /([ab])([ax])\1x\1/
is run on the string aaxaxa
what is the resulting value of $1
and $2
.
Can some one explain in detailed in perl context.
I have tried with below perl script; Got an answer. But I would like to understand what does that regex is doing and how the answer came.
#! /usr/bin/perl
use strict;
use warnings;
my $str = "aaxaxa";
my($str1,$str2) = ($str =~ m/([ab])([ax])\1x\1/);
print "Substring-1: $str1 Substring-2: $str2 \n";
Output : Substring-1: a Substring-2: x