fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String xml = "<?xml version=\\\"1.0\\\"?>\n" +
  13. "<1>\n" +
  14. "<TITLE>A Sample Article</TITLE>\n" +
  15. "<SECT>The First Major Section <PARA>This section will introduce a subsection.</PARA>\n" +
  16. " <2>\n" +
  17. " <SECT>The Subsection Heading <PARA>This is the text of the subsection. </PARA> \n" +
  18. " </SECT>\n" +
  19. "</SECT>\n" +
  20. "</ARTICLE>";
  21. xml = xml.replaceAll("<[12]>", "");
  22. System.out.println(xml);
  23. }
  24. }
Success #stdin #stdout 0.04s 320576KB
stdin
Standard input is empty
stdout
<?xml version=\"1.0\"?>

<TITLE>A Sample Article</TITLE>
<SECT>The First Major Section      <PARA>This section will introduce a subsection.</PARA>
    
    <SECT>The Subsection Heading         <PARA>This is the text of the subsection.         </PARA>      
    </SECT>
</SECT>
</ARTICLE>