in reply to Question for regex experts
You can replace the entities even if they are already right with s{ \&? \b (amp|lt|gt) ; }{&$1;}xg;. And you can generate the OR list (in parenthesis) with a map. Edit : Here the &? catches the ampersand if it's there so that the substitution does not add another one. The \b makes sure that you have something that looks like a failed HTML entity. You wouldn't want "Tom bought a lamp; he loves lamps" to become "Tom bought a l& he loves lamps" for example.
|
|---|