Dear Monks I have a xml file like this:
</S></TEXT><TEXT><S Entail="142" s_id="0"> Annan urges return to democracy in <REF C-ENTID="Nepal" EXT="Nepal" ID +="104" S&#1058;YPE="PROPNAME">Nepal</REF></S><S Entail="138-139-142" +s_id="1"> UN Secretary General Kofi Annan on Tuesday expressed deep concern over + events in <REF A-CLASS="No-Reference" A-REFTYPE="Entity" C-ENTID="Ne +pal" EXT="Nepal" ID="105" S&#1058;YPE="PROPNAME">Nepal</REF> and urge +d a return to democracy, after <REF C-ENTID="King Gyanendra Bir Bikra +m" COMMENT="Coref direction is forward" EXT="King Gyanendra Bir Bikra +m" ID="100" S&#1058;YPE="APNAME">King Gyanendra Bir Bikram</REF> dismissed <REF A-CLASS="Entity-Entity" A-DIR="Backward" A-RELTYPE="Ide +ntity" A-RESTYPE="Intra" A-TYPE="Referential" ANT-ID="105" ID="101">t +he country</REF> 's coalition government and imposed an indefinite st +ate of emergency. </S><S Entail="138-139-143" s_id="2">
I tried using regular expression and sed to get rid of all <REF .......> elements so my desired output would look like this:
</S></TEXT><TEXT><S Entail="142" s_id="0"> Annan urges return to democracy in Nepal</REF></S><S Entail="138-139-1 +42" s_id="1"> UN Secretary General Kofi Annan on Tuesday expressed deep concern over + events in Nepal</REF> and urged a return to democracy, after King Gy +anendra Bir Bikram</REF> dismissed the country</REF> 's coalition government and imposed an ind +efinite state of emergency. </S><S Entail="138-139-143" s_id="2">
I had a sed line like this which does not work well :(
sed -r 's/<REF ([A-Za-z]*[-]{0,1}[A-Za-z]*=["].[A-Za-z0-9-]*.{0,1}[A-Z +a-z0-9-]*.{0,1}[A-Za-z0-9-]*.{0,1}[A-Za-z0-9-]*.{0,1}[A-Za-z0-9-]*.{0 +,1}[A-Za-z0-9-]*.{0,1}[A-Za-z0-9-]*.{0,1}[A-Za-z0-9-]*)*>//g' input.x +ml
Any idea how can I do it with perl? I do really appreciate :) Thanks

In reply to problem with removing something in XML file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.