Maybe I'm missing something here, but have you looked at HTML::Entities? If you don't want to include another module, you could probably rip out the necessary guts from it to do what you want, but it's a pretty light-weight module anyway.
In reply to Re: Regex to encode entities in XML
by ChemBoy
in thread Regex to encode entities in XML
by epoptai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |