Perl code question


I have below code :

my($abc) = "fred<hello>3hello"; 
$abc =~ /^[^\\d]{2,4}<([^>]+)>\\d?\\1$/; 

if (defined($1)) { 
print "$1\
} else { 
print "not found\


What is the code doing ?? what function of the regular expression

$abc =~ /^[^\\d]{2,4}<([^>]+)>\\d?\\1$/; 

Please advice what it do ??

This regular expression is searching for the following things in this order:
strings starting with between 2 and 4 characters that are not digits
the < character
capturing everything afterward that is not the > character
the > character
maybe 1 digit
the previously captured information
end of line

Your code would then print the captured data or print “not found”
So your pattern would match and print the following:
fred<hello>3hello —prints—> hello
fr<h>h —prints—> h
fr<h>4h —prints—> h
fre<he>4he —prints—> he
fre<he>he —prints—> he
fre< >he —prints (note there is a space after the final e)—>

The pattern would not match the following:
fred<hello>3 hello —the space after the 3 isn’t allowed in the pattern—
fr<h>he —the last letters need to match what’s inside the angle brackets—
fredf<h>4h —there are too many nondigits at the start, max 4—
e<he>4he —there are not enough nondigits at the start, min 2—
fre<>>> —the pattern finds the first > as the closing one—
fre<>he —the pattern must have at least one non-right angle bracket in between the angle brackets