Although nowadays I'd prefer to use HTML::Parser or something similar, I think you could use a subroutine call in the replacement part (and use the /e modifier).
sub foo { my $bar = shift; if ( $CONDITION ) { #modify $bar if you need to } return $bar; } my $text =~ s{(<img.+?>)}{foo($1)}sige;
update1: changed quantifier to +?
In reply to Re: Conditional regex
by linuxer
in thread Conditional regex
by sherab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |