Re: Eliminate characters from line?

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/passing-arguments-to-Image-Sequence-tp3702558p3702560.html

On Jun 7, 2006, at 10:53 AM, Andy Weller wrote:

> In relation to below, how would I eliminate both starting and
> trailing characters, just capturing a middle component? For
> example, if I receive the following:
>
> 50037631 5 2 1 164325 2 1 35 45 1
>
> I am interested in just the "164325" part. So I guess I remove
> the first n characters with:
>
> answer = substring(answer, n, lengthOf(answer));
>
> but how the remaining m characters?

Call substring twice, first to remove the starting characters and a
second time to remove the trailing characters.

     s = "50037631 5 2 1 164325 2 1 35 45 1";
     s2 = substring(s, 15, lengthOf(s));
     s2 = substring(s2, 0, 6);
     print(s2);

Or you can use the split() function to get the 5th of n space delimited
numbers.

     numbers = split(s);
     print(numbers[4]);

-wayne