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, |
In reply to Re: Need a regex to replace incomplete html entities
by Athanasius
in thread Need a regex to replace incomplete html entities
by Chris Daniel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |