in reply to Replacing multiple matches

my %replacement = ( A => 'B', C => 'D', ); my $loop_line = '[A]A[C]C'; $loop_line =~ s/\[([^\]]+)\]/$replacement{$1}/g; print "$loop_line\n";

Replies are listed 'Best First'.
Re: Re: Replacing multiple matches
by alongwor (Novice) on Feb 16, 2004 at 11:49 UTC
    Thank you all that replied. Especially so quickly. My problem is now solved - I really should master regex one day as it is often where I have trouble. Thanks again.......