AtomicValue arg3 = (AtomicValue) argument[3].evaluateItem(c);
flags = arg3.getStringValueCS();
}
try {
ARegularExpression re = new ARegularExpression(arg1.getStringValueCS(), flags.toString(), "XP20", null);
// check that it's not a pattern that matches ""
if (re.matches("")) {
dynamicError(
"The regular expression in replace() must not be one that matches a zero-length string",
"FORX0003", c);
}
String input = arg0.getStringValue();
CharSequence res = re.replace(input, replacement);
return StringValue.makeStringValue(res);
} catch (XPathException err) {
XPathException de = new XPathException(err);
de.setErrorCode("FORX0002");
de.setXPathContext(c);