in reply to Need a regex to replace incomplete html entities
Hello Chris Daniel, and welcome to the Monastery!
Please note that your requirement as stated is self-contradictory. I assume you don’t want to remove the entity &. In which case, you can use a negative lookahead assertion to ensure that the entity to be removed is not immediately followed by another digit:
20:54 >perl -wE "my $x = '<Remarks>1 SW PLT SLAC 6 PCS </Remarks>'; + $x =~ s/&#\d(?!\d)//g; say $x;" <Remarks>1 SW PLT SLAC 6 PCS </Remarks> 20:54 >perl -wE "my $x = '<Remarks>1 SW PLT SLAC 6 PCS &</Remarks>' +; $x =~ s/&#\d(?!\d)//g; say $x;" <Remarks>1 SW PLT SLAC 6 PCS &</Remarks> 20:54 >
See “Lookaround Assertions” in perlre#Extended-Patterns.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|