Re: Make an escaped string in IJ macro language
Posted by
lechristophe on
Dec 13, 2016; 11:40am
URL: http://imagej.273.s1.nabble.com/Make-an-escaped-string-in-IJ-macro-language-tp5017770p5017771.html
I did it with this ugly thing :
function escapePath(p) {
if (indexOf(p, "\\") > 0) {
pE = split(p, "\\");
pF = ""+ pE[0] + "\\" + "\\";
for (i = 1; i < pE.length; i++) {
pF = pF + pE[i] + "\\" + "\\";
}
}
else {
pF = p;
}
print(pF);
return pF;
}
but a proper replacement string would be nicer (could never wrap my head
around regex syntax)
Christophe
On Tue, Dec 13, 2016 at 12:12 PM, Christophe Leterrier <
[hidden email]> wrote:
> Hi,
>
> I'm trying to make a properly escaped string from a non-escaped Windows
> path string, i.e.
>
> from
> C:\Users\christo\161212(test ABL b2s)\Locs\
> to
> C:\\Users\\christo\\161212(test ABL b2s)\\Locs\\
>
> however both
> replace(path, "\\", "\\\\")
> and
> replace(path, "\\", File.separator+File.separator)
> throw a regex error.
>
> How should I devise the replacement string "\\" to be handled by the
> "replace" macro function?
>
> Thanks,
>
> Christophe
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html