4. delete-text

delete-text(pattern, flags?, from?)

Delete text matching regular expression pattern from node from. Parameter from defaults to the context node. The text is deleted no matter the node containing it: node from, descendants of node from or a mix between node from and its descendants.

Optional flags may be used to parametrize the behavior of the regular expression:


Delete all occurrences of pattern.


Operate in multi-line mode. In multi-line mode, the expressions ^ and $ match just after or just before, respectively, a line terminator or the end of the input sequence. By default, these expressions only match at the beginning and the end of the entire input sequence.


Operate in single line mode. In single line mode, the expression . matches any character, including a line terminator. By default, this expression does not match line terminators.


Operate in case-insensitive mode (in a manner consistent with the Unicode Standard).


Treat the pattern as a sequence of literal characters.

Regular expression reference: java.util.regex.Pattern.



delete-text("\n", "as");

delete-text("^\s+", "", $div);