Re: substring
Posted by
Ben Tupper on
Oct 01, 2008; 4:08pm
URL: http://imagej.273.s1.nabble.com/substring-tp3694891p3694894.html
Hi,
On Oct 1, 2008, at 11:57 AM, Johannes Breu wrote:
> Hello,
>
> I have problems with substring or I don´t get the definition.
> *
> substring(string, index)*
> Returns a substring of *string* that begins at *index* and extends
> to the
> end of *string*.
>
The index value must be a zero-based position for the substring to
begin. I think you want to add a step using indexOf()
str = "C:\Dokumente und Einstellungen\Johannes Breu\Eigene Dateien
\Platz\Images\IN12/Image0006.tif";
ix = indexOf(str, "Images");
n = substring(str, ix);
print(n);
I just noticed that on my Mac OSX (ImageJ 1.41) the forward slash
disappears but it might work on you Windows machine just fine.
Cheers,
Ben
> Assume that this is dir: C:\Dokumente und Einstellungen\Johannes
> Breu\Eigene
> Dateien\Platz\Images\IN12/Image0006.tif
>
> m=dir;
> u="Images";
> n=substring (m,u);
> print(n);
>
> Now I expect n=Images\IN12/Image0006.tif
>
> Instead of this I get an error message:
> n=substring (m,u<)>;
>
> What´s wrong?