use v5.12; use warnings; use HTML::Entities; use Data::Dump qw/pp dd/; use utf8; my $sep = decode_entities('✶'); my $pat = "{${sep}Adjektive (Nominalflexion)~87$sep}"; my $text = join " foo \n", ($pat) x 2; pp $text; my $b = "Adjektive (Nominalflexion)~87"; my $c = "\Q{$sep$b$sep}\E"; my $r = "
some Text $b some other text
"; $text =~ s/$c/$r/sg; pp $text; #### -*- mode: compilation; default-directory: "d:/tmp/pm/" -*- Compilation started at Tue Nov 23 13:06:24 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/nominal_flexion.pl "{\x{2736}Adjektive (Nominalflexion)~87\x{2736}} foo \n{\x{2736}Adjektive (Nominalflexion)~87\x{2736}}" "
some Text Adjektive (Nominalflexion)~87 some other text
foo \n
some Text Adjektive (Nominalflexion)~87 some other text
" Compilation finished at Tue Nov 23 13:06:24