Using split() method you are receiving an array - not a string ==> myPath is an array with 2 elements.
If you are alerting a result - it is viewed like this, couse array's elements are "," delimited.
To call a number part use myPath
thank you worked as a charm you are a BEAST!
haahah thanks mate
From the Mozilla help page:
The split() method splits a String object into an array of strings by separating the string into substring"
var str = "/xxxxx/xxxx/xxxx/341542"; var s = str.split( "/" ); alert (s); alert (s[s.length-1]);
Don't know what quicker but in this case it's not going to matter
@Mark – that's much better.
We have to take into account, that on Mac OSX the character "/" is a regular one and can be part of any file name or folder name. Not just a folder name separator. Just a fair warning …
Even Better ?
var myPath = File($.fileName).parent.parent.parent.name
in my opinion on Mac OSX path.fullname also get the folderpath separated with "/"
Isn't it so?
But back to the problem.
The best way is to use name instead of fullname:
Otherwise with the match function:
If there are no digits at the end of the path - the result is null and match fails.
I'm with Trevor and Kai Rübsamen: .match(/[\/:]\d+$/) or the split method should be the best in this case.