Trim String?

So I have a file location being returned from a function…something like this:

 

/var/mobile/Applications/588C26BC-8720-4AD4-899F-CF404BF0EAE9/Documents/0001.tar

 

I’d like to trim everything off so that I’m left with just the filename “0001.tar”.  I’ve seen how I could do this by counting up to the position of the filename and then trimming, like this -

 

print(.sub(tempString,1,15)) – Will print the first part of ‘tempString’ from 1 to the 15th character.

 

But, I’d rather just grab the last 8 positions of the string because I know the filename will always be 8 positions long.  So, instead of starting at the beginning of the string and counting forward, I’d like to start at the end of the string and count backwards 8 positions.

 

How would I do that?

Thanks.

Brian

Ok…found it.  Answered my own question.

 

print( myString:sub(-8) )

 

Thanks!

Ok…found it.  Answered my own question.

 

print( myString:sub(-8) )

 

Thanks!

@vanheuverswyn,

Thanks for the post! Helped me a lot. 

@vanheuverswyn,

Thanks for the post! Helped me a lot.