void () { final ReplacementVariableDefinition definition = new ReplacementVariableDefinition("result"); definition.setScriptCodeConstraint("value.getText().toInteger() + 1"); options.addVariableDefinition(definition); String in = """ <!doctype html> <html> <head> <title class="EXAMPLE">Structural Replace Example</title> <body> <ul> <li class="EXAMPLE">2<!--comment--></li> <li class="example">3</li> <li class="EXAMPLE">4</li> <li class="example">Example line a</li> <li id="EXAMPLE">6</li> </ul> </body> </html> """; String what = "<li>'value:[regex( \\d+ )]</li>"; String by = "$result$"; final String expected = """ <!doctype html> <html> <head> <title class="EXAMPLE">Structural Replace Example</title> <body> <ul> <li class="EXAMPLE">3<!--comment--></li> <li class="example">4</li> <li class="EXAMPLE">5</li> <li class="example">Example line a</li> <li id="EXAMPLE">7</li> </ul> </body> </html> """; assertEquals(expected, replace(in, what, by)); }