Something like this, perhaps:
#!/usr/bin/perl use strict; use warnings; my %replace = ( Not => 'Just', Stupid => 'Perl', ); my $string = "[Not] Another [Stupid] Hacker"; $string =~ s/\[([^\]]+)\]/$replace{$1}/g; print $string, $/; __OUTPUT__ Just Another Perl Hacker
In reply to Re: Replacing multiple matches
by edan
in thread Replacing multiple matches
by alongwor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |