Simone Gianni wrote:
Hi Luca,
Luca Morandini wrote:
Hmmm... "replace" is a JavaScript function, not a Java one, hence I
cannot understand how the string differences apply :(
Anyway, I tried:
var jfilters= new Packages.java.lang.String(filters);
var re= new Packages.java.lang.String("/a/g");
var s= new Packages.java.lang.String("b");
jfilters.replace(re, b);
Nope, in this case you are not calling the javascript replace function,
which accept the /a/g syntax, but the java.lang.String.replace(char,
char) method, which only accept two chars.
Got it... a bit confusing though.
How is the filter variable declared?
It's declared as "var filters", but it's returned by a JavaScript
function that set its value as: outStream.toString(), where
var outStream= new Packages.java.io.ByteArrayOutputStream()
...hence, it is a Java String in the end.
You could try one of the following :
var jsfilters = new String(filter);
var jsfilters = filters + '';
and then :
jsfilters.replace(/a/g,'b');
Ok, I did the following:
var jsfilters= new String(filters);
cocoon.log.debug("XXX updateMap: filters pre: " + jsfilters);
jsfilters.replace(/i/g, "x");
cocoon.log.debug("XXX updateMap: filters post: " + jsfilters);
...and it works :)
Thanks for Simone and Alessandro for their help in sorting this out.
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]