can anyone tell me if rhino properly supports the replace function in javascript, as i have an example and it doesn't seem to.
all it seems to do is redirect the call to java replace.
i have a replace(/,/gi,";"); (the g means replace all and the i means ignore case)
can anyone tell me how to make this work properly, or when it might be added.
if its not going to be added anytime soon, then could someone be kind enough to tell me what to change in rhino itself so i can get it to work, and i will submit my fix to you for inspection
> can anyone tell me if rhino properly supports the replace function in > javascript, as i have an example and it doesn't seem to.
> all it seems to do is redirect the call to java replace.
> i have a replace(/,/gi,";"); (the g means replace all and the i means > ignore case)
> can anyone tell me how to make this work properly, or when it might be > added.
> if its not going to be added anytime soon, then could someone be kind > enough to tell me what to change in rhino itself so i can get it to > work, and i will submit my fix to you for inspection
> regards > chris wade
The replace function is completely implemented as far as I know:
js> var s = "Hi, Mom"; js> s.replace(/m/gi, 'b'); Hi, bob
can anyone tell me if rhino properly supports the replace function in javascript, as i have an example and it doesn't seem to.
all it seems to do is redirect the call to java replace.
i have a replace(/,/gi,";"); (the g means replace all and the i means ignore case)
can anyone tell me how to make this work properly, or when it might be added.
if its not going to be added anytime soon, then could someone be kind enough to tell me what to change in rhino itself so i can get it to work, and i will submit my fix to you for inspection
> can anyone tell me if rhino properly supports the replace function in > javascript, as i have an example and it doesn't seem to.
> all it seems to do is redirect the call to java replace.
> i have a replace(/,/gi,";"); (the g means replace all and the i means > ignore case)
> can anyone tell me how to make this work properly, or when it might be > added.
> if its not going to be added anytime soon, then could someone be kind > enough to tell me what to change in rhino itself so i can get it to > work, and i will submit my fix to you for inspection
> regards > chris wade
Chris,
You have a reference to a java.lang.String. Try wrapping it in a javascript string:
Rhino 1.7 release 1 2008 10 20 js> s = new java.lang.String("Hi Mom") Hi Mom js> s.replace(/m/gi,'b') js: "<stdin>", line 3: The choice of Java constructor replace matching JavaScript argument types (function,string) is ambiguous; candidate constructors are: class java.lang.String replace(char,char) class java.lang.String replace (java.lang.CharSequence,java.lang.CharSequence) at <stdin>:3