Horst.Lohnstein has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a question concerning Regex with HTML::Entities. I try to replace patterns with a keyword with some HTML-Code: The keword is encapsulated between ✶ (a little star). The keyword itself is of the form: Adjektive (Nominalflexion~84. The whole pattern looks like: {✶Adjektive (Nominalflexion)~87✶}
use HTML::Entities; # $text is some Text from a mysql database my $sep = decode_entities('✶'); my @v = ($text =~ /\{$sep(.*?)$sep\}/sg); # alle Verweise # @v contains all patterns (which means that they match)
The matched elements in @v have the form: {✶Adjektive (Nominalflexion)~87✶} Going through all elements in @v, I try to replace the matched elements in the following way:
$b = "Adjektive (Nominalflexion)~87"; $c = "\{$sep$b$sep\}"; $r = "<div>some Text $b some other text</div>"; $text =~ s/$c/$r/s;
I tried a lot of variants including quotes (?:...), and what not. Nothing worked! Is there anyone, who can stop my wasting of time with these questions? Thanks in advance! Best regards, Horst
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex with HTML::Entities
by Fletch (Bishop) on Nov 23, 2021 at 07:33 UTC | |
by Horst.Lohnstein (Novice) on Nov 23, 2021 at 08:57 UTC | |
by Fletch (Bishop) on Nov 23, 2021 at 09:13 UTC | |
by ikegami (Patriarch) on Nov 23, 2021 at 15:00 UTC | |
|
Re: Regex with HTML::Entities
by LanX (Saint) on Nov 23, 2021 at 12:07 UTC | |
|
Re: Regex with HTML::Entities
by Horst.Lohnstein (Novice) on Nov 23, 2021 at 17:38 UTC | |
by ikegami (Patriarch) on Nov 24, 2021 at 03:54 UTC |