in reply to String replace
my $text="The respondent uses the following products XXX, YYYYYYYYY, Z +ZZZZZZ around the house and they are considering using QQQQQQQ too. T +hey are particularly impressed with ZZZZZZZ."; my %replace=( "XXX" => "AAA", "YYYYYYYYY" => "BBBBBB", "ZZZZZZZ" => "CCCCCC", "QQQQQQQ" => "DDDDDDDD"); my $search=join '|',keys %replace; $text=~s/($search)/$replace{$1}/g; print $text;
|
|---|