Don't know what to tell you other than try providing a SSCCE that can actually be run. This below works as I expect it so you're doing something strange or (entirely possible) your problem statement's being misread.

(Also the <code> formatting is doing weird things but I actually have literal ✶ in my source and the output where it's being replaced with the entity below everywhere save the initialization of $wonky_char. Not sure what's the right way to get literal UTF8 chars in sample code using utf8.)

#!/usr/bin/env perl use 5.034; use HTML::Entities qw( decode_entities ); use utf8; my $input = qq{{&#10038;Adjektive (Nominalflexion)~87&#10038;}}; my $wonky_char = decode_entities( q{&#10038;} ); binmode( STDOUT, q{:utf8} ); say qq{\$input: $input}; say qq{\$wonky_char: $wonky_char}; my $to_match = "Adjektive (Nominalflexion)~87"; my $new_string = $input =~ s{\{$wonky_char(\Q$to_match\E)$wonky_char\}}{<div>I found +'$1'</div>}r; say qq{\$new_string: $new_string}; my $cleaner_regex_sample = $input =~ s{ \{ $wonky_char (\Q$to_match\E) $wonky_char \} }{<div>Al +so found '$1'</div>}rx; say qq{cleaner: $cleaner_regex_sample}; exit 0; __END__ $input: {&#10038;Adjektive (Nominalflexion)~87&#10038;} $wonky_char: &#10038; $new_string: <div>I found 'Adjektive (Nominalflexion)~87'</div> cleaner: <div>Also found 'Adjektive (Nominalflexion)~87'</div>

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re^3: Regex with HTML::Entities by Fletch
in thread Regex with HTML::Entities by Horst.Lohnstein

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.