perl - How can I filter '?' out of XML? -
perl - How can I filter '?' out of XML? -
i have xml info this:
class="lang-xml prettyprint-override"><?xml version="1.0"?> <a> <b>someone ? messed up</b> <c>this question mark has disappear too?</c> </a>
now object validate if every opening tag has closing one, , filter out question marks in between <b>
tags using perl.
i tried different variations of
$_[0] =~ s|>(.*)\?(.*)<|>$1$2<|g;
but cuts off <?
, ?>
. how can work without ruining xml version tag? also, using xml::simple
overkill checking if tags closed properly?
regex not best solution fix xml.
to prepare regex question mark thing this kind of flawed regex. flawed because fixes single ?
.
s/>([^<>]*?)[ ]?\?[ ]?([^<>]+?)</>$1 $2</g
# >([^<>]*?)[ ]?\?[ ]?([^<>]+?)< > ( [^<>]*? ) [ ]? \? [ ]? ( [^<>]+? ) <
xml perl
Comments
Post a Comment