Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Regex with HTML::Entities

by LanX (Saint)
on Nov 23, 2021 at 12:07 UTC ( [id://11139053]=note: print w/replies, xml ) Need Help??


in reply to Regex with HTML::Entities

This works for me:
use v5.12; use warnings; use HTML::Entities; use Data::Dump qw/pp dd/; use utf8; my $sep = decode_entities('&#10038;'); 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 = "<div>some Text $b some other text</div>"; $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}Adjekt +ive (Nominalflexion)~87\x{2736}}" "<div>some Text Adjektive (Nominalflexion)~87 some other text</div> fo +o \n<div>some Text Adjektive (Nominalflexion)~87 some other text</div +>" Compilation finished at Tue Nov 23 13:06:24

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found