and the output would be 'this is a bar'my $regex = "foo"; #any pattern, few characters here for simplicity my $string = "this is a foo"; $string =~ s/$regex/'bar'/ge; print $string;
In reply to $variable as regex in s/// by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |