in reply to Re: Removing XML comments with regex
in thread Removing XML comments with regex
You could do something like this: $xml =~ s/<!--.*?-->//g;
Update: You can use the fact that '--' may not occur in xml comments:
$xml =~ s/<!--(?:.(?<!--))*-->//g;
Sadly lookarounds are error prone (from the programmer's side), so don't trust this regex unless you've tested it carefully. I don't think there is a big speed gain in it (if at all), I hope I find the tuits to benchmark it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Removing XML comments with regex
by Fletch (Bishop) on Oct 24, 2007 at 19:39 UTC | |
| |
|
Re^3: Removing XML comments with regex
by gamache (Friar) on Oct 24, 2007 at 19:37 UTC | |
by tuxz0r (Pilgrim) on Oct 24, 2007 at 19:41 UTC |