void () { String s1 = "<a/>"; String s2 = "<a/>"; String s3 = "<a><b/></a>"; String expectedResult = "<a><b/></a>"; assertEquals("First tag replacement", expectedResult, replace(s1, s2, s3)); String s4 = """ <group id="EditorTabPopupMenu"> <reference id="Compile"/> <reference id="RunContextPopupGroup"/> <reference id="ValidateXml"/> <separator/> <reference id="VersionControlsGroup"/> <separator/> <reference id="ExternalToolsGroup"/> </group>"""; String s5 = "<reference id=\"'_Value\"/>"; String s6 = "<reference ref=\"$Value$\"/>"; expectedResult = """ <group id="EditorTabPopupMenu"> <reference ref="Compile"/> <reference ref="RunContextPopupGroup"/> <reference ref="ValidateXml"/> <separator/> <reference ref="VersionControlsGroup"/> <separator/> <reference ref="ExternalToolsGroup"/> </group>"""; assertEquals("Replace tag", expectedResult, replace(s4, s5, s6)); String s7 = "<h4 class=\"a\">My title<aaa>ZZZZ</aaa> My title 3</h4>\n" + "<h4>My title 2</h4>"; String s8 = "<h4 class=\"a\">'_Content*</h4>"; String s9 = "<h5>$Content$</h5>"; expectedResult = "<h5>My title <aaa>ZZZZ</aaa> My title 3</h5>\n" + "<h4>My title 2</h4>"; assertEquals("Replace tag saving content", expectedResult, replace(s7, s8, s9)); expectedResult = "\n" + "<h4>My title 2</h4>"; assertEquals("Delete tag", expectedResult, replace(s7, s8, "")); String what = "<'_H:h4 class=\"a\">'_Content*</'_H>"; String by = "<$H$>$Content$</$H$>"; expectedResult = "<h4>My title <aaa>ZZZZ</aaa> My title 3</h4>\n" + "<h4>My title 2</h4>"; assertEquals("Replace with variable", expectedResult, replace(s7, what, by)); String in = "<b>Cry 'Havoc!', and <i>let slip the<br> dogs of war</i></b>"; what = "<'_Tag:b >'_Content2*</'_Tag>"; by = "<$Tag$ id=\"unique\">$Content2$</$Tag$>"; expectedResult = "<b id=\"unique\">Cry 'Havoc!', and <i>let slip the<br> dogs of war</i></b>"; assertEquals("Replace complex content with variable", expectedResult, replace(in, what, by)); }