my $str = "<SampleElement oldattribs=\"sa1 sa2 sa3\">";
$str =~ s#<SampleElement[^>]*oldattribs="([^"]*)"#
my $fulcnt=$&;
my $afids=$1;
my @affs = ();
if($afids =~ m/\s+/) {
@affs = split /\s/, $afids;
my $jnafs = join ",", map { $_=~s/[a-z]*//i, } @affs;
($fulcnt." newattribs=\"$jnafs\"");
}
else {
($fulcnt);
}
#eg;
My Output:
<SampleElement oldattribs="sa1 sa2 sa3" newattribs="1,1,1">
Expected Output:
<SampleElement oldattribs="sa1 sa2 sa3" newattribs="1,2,3">
Someone could point out me where I am doing wrong. Thanks in advance.
\d+)\s*! $+{f} ? $+{f} : $+{s}.","!egr]e;`](https://ideone.com/KwEapL).