Substring Title names issues

Dear all,
I have written this macro:

N0 = getTitle(); //N means name
imageToSelectString1 = substring(N0, indexOf(N0,“Position”), lastIndexOf(N0," “+number+” "));

The idea is to retrieve from the title of my images the Position+number.

Name structure: Position+(space)+number+(space)+other letter…

But I have billions of images so I want imageJ to recognize any number so automatically takes the number from the title.

Can anyone help me with this code?

You can use:
parseInt(string)
to get an integer value out of a string. When I’ve used similar methods in other languages it ignores whitespace (haven’t verified this with ImageJ though), so you could do:

i = indexOf(N0, " ")
parseInt(substring(N0, i, indexOf(N0, " ", i+1));

That should work if the first space in the title is before the number you need.

Many thanks this helped a lot!
Miguel