* Evaluate the function in a string context
*/
public Item evaluateItem(XPathContext c) throws XPathException {
AtomicValue arg0 = (AtomicValue) argument[0].evaluateItem(c);
if (arg0 == null) {
arg0 = StringValue.EMPTY_STRING;
}
AtomicValue arg2 = (AtomicValue) argument[2].evaluateItem(c);
CharSequence replacement = arg2.getStringValueCS();
String msg = checkReplacement(replacement);
if (msg != null) {
dynamicError(msg, "FORX0004", c);
}
AtomicValue arg1 = (AtomicValue) argument[1].evaluateItem(c);
CharSequence flags;
if (argument.length == 3) {
flags = "";
} else {
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 ""