I have that javascript code for a RhinoScript based framework:
function cleaner(tracker) {
var nRegex = new RegExp(reggo);
var regexMatch = tracker.match(nRegex);
if (regexMatch == null || regexMatch == "" || regexMatch.length <= 0) {
return tracker;
}
tracker = tracker.replace(nRegex, "");
return tracker;
}
However I get that exception for it:
Exception: InternalError: The choice of Java constructor replace matching JavaScript argument types (function,string) is ambiguous; candidate constructors are: class java.lang.String replace(java.lang.CharSequence,java.lang.CharSequence) class java.lang.String replace(char,char) (#114)
I've tried something but didn't work as expected. Any ideas?
It looks like "tracker" in this case is a Java object but you expect it to be a JS string. You'll need to debug your other code to find out what it's being set to.
If the behavior was intentional and you really did want to choose one Java method or the other, you could do it by changing:
tracker = tracker.replace(nRegex, "");
To:
tracker = tracker['replace(char,char)'](nRegex, "");
// ...or...
tracker = tracker['replace(java.lang.CharSequence,java.lang.CharSequence)'](nRegex, "");
But of course, nRegex in this case was probably not meant to be a char or CharSequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With