http://qs1969.pair.com?node_id=1041001


in reply to Question for regex experts

perl -e '$x=qw(&apm;gt;lt;amp;);$x=~s/;(.)/;&$1/g;print $x,"\n";'

Replies are listed 'Best First'.
Re^2: Question for regex experts
by evgen-i (Novice) on Jun 27, 2013 at 12:29 UTC
    Thanks, but this is just a solution for this particular example; I need a general solution for any codes.

      You need to implement a lookup table that contains a list of all possible, or otherwise a subset, of HTML character codes.

      Therefore, each time your program encounters

      code;
      instead of
      &code;
      , it will need to add an ampersand at the start.