in reply to Re^5: Thanks to Ikegami, Chromatic & Corion
in thread Thanks to Ikegami, Chromatic & Corion

The escapes need to be the other way around!

my %escapes = ( '&lab;' => '<', '&rab;' => '>', '&lcb;' => '(', '&rcb;' => ')', '&lsb;' => '[', '&rsb;' => ']' );

I need a new escapes_re, because now it's simply destroying all the brackets!

Replies are listed 'Best First'.
Re^7: Thanks to Ikegami, Chromatic & Corion
by Anonymous Monk on Nov 02, 2011 at 02:37 UTC

    I need a new escapes_re, because now it's simply destroying all the brackets!

    Eeeep!

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^7: Thanks to Ikegami, Chromatic & Corion
by Logicus (Initiate) on Nov 02, 2011 at 02:37 UTC

    Got it!

    my %escapes = ( '&lab;' => '<', '&rab;' => '>', '&lcb;' => '(', '&rcb;' => ')', '&lsb;' => '[', '&rsb;' => ']' ); my $escapes_re = qr/&[lr][acs]b;/; $aXML =~ s/($escapes_re)/$escapes{$1}/g;

      That won't work. you need to handle those sequences, <special> and <post_include> at the same time, not before (which would break "&lab;special>lab&lab;/special>") or after (which would break "<special>lab</special>"). I've covered what would work elsewhere.

      A reply falls below the community's threshold of quality. You may see it by logging in.