http://imagej.273.s1.nabble.com/s-replace-question-tp5023836p5023844.html
> On Aug 11, 2020, at 5:05 PM, Cammer, Michael <
[hidden email]> wrote:
>
> I have been trying to remove parentheses from a string using the s.replace command and have been getting strange results. (Practically, I was able to solve the problem by cutting the string apart, trimming out the parentheses and reassembling the string, but am asking specifically about the s.replace behavior.)
>
>
> Code such as this
>
> newTitle = newTitle.replace("(", "");
>
> returns an error message.
This bug is fixed in the ImageJ 1.53c63 daily build.
>
>
> Therefore, I tried setting a variable to "()" and used the following syntax:
>
> print("Before trying to replace parentheses: " + newTitle);
> parentheses = fromCharCode(40, 41);
> print(parentheses);
> newTitle = newTitle.replace(parentheses, "");
> newTitle = newTitle + IJ.pad(i, 3);
> print("Processed: " + newTitle);
> with output that does not remove the parentheses:
>
> Original: c:3/3 - KO_1 nM_rep2_007.nd2 (series 1)
> Before trying to replace parentheses: KO_1 nM_rep2_007 ()
> ()
> Processed: KO_1 nM_rep2_007 ()027
>
> And odder, the output in this case inserts "xx" between every character:
>
>
> print("Before trying to replace parentheses: " + newTitle);
> parentheses = fromCharCode(40, 41);
> print(parentheses);
> newTitle = newTitle.replace(parentheses, "xx");
> newTitle = newTitle + IJ.pad(i, 3);
> print("Processed: " + newTitle);
>
>
>
> Original: c:3/3 - KO_1 nM_rep2_007.nd2 (series 1)
> Before trying to replace parentheses: KO_1 nM_rep2_007 ()
> ()
> Processed: xxKxxOxx_xx1xx xxnxxMxx_xxrxxexxpxx2xx_xx0xx0xx7xx xx(xx)xx027
>
>
>
> Any ideas?
>
>
> Thank you!
>
>
> Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory
>
> NYU Langone Health, 540 First Avenue, SK2 Microscopy Suite, New York, NY 10016
>
>
[hidden email]<mailto:
[hidden email]>
http://nyulmc.org/micros http://microscopynotes.com/>
> Voice direct only, no text or messages: 1-914-309-3270 and 1-646-501-0567
>
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html