Copy link to clipboard
Copied
Hi All,
Is it possible to split the file name and get the outputs shown below.
140357-XXXX_r1414_WP-book8_994x1163_CMYK_v2
output: 140357-XXXX
140357-XXXX-141863_r1414_AS2-BRAND-WALL-GPF2_3000x1285_CMYK_v2
output: 140357-XXXX
140357_r1414_WP-book8_994x1163_CMYK__XXXX_v2
output: 140357-XXXX
141863_r1414_AS2-TEST-BOOK-GPF2_3000x1285_CMYK_140357__XXXX_v2
output: 140357-XXXX
Sure. String.split(separator) returns an array of strings broken up by the separator, excluding the separator.
Your first example is:
var ns = myDoc.name.split("-");
ns = ns[0] + "-" + ns[1].split("_")[0];
Your second example is:
var ns = myDoc.name.split("-");
ns = ns[0] + "-" + ns[1];
Third example is:
var ns = myDoc.name.split("_");
ns = ns[0] + "-" + ns[6]; //double underscore is split twice, with first instance of split being an empty string
Fourth example is:
var ns = myDoc.name.
...Copy link to clipboard
Copied
Sure. String.split(separator) returns an array of strings broken up by the separator, excluding the separator.
Your first example is:
var ns = myDoc.name.split("-");
ns = ns[0] + "-" + ns[1].split("_")[0];
Your second example is:
var ns = myDoc.name.split("-");
ns = ns[0] + "-" + ns[1];
Third example is:
var ns = myDoc.name.split("_");
ns = ns[0] + "-" + ns[6]; //double underscore is split twice, with first instance of split being an empty string
Fourth example is:
var ns = myDoc.name.split("_");
ns = ns[5] + "-" + ns[7]; //double underscore is split twice, with first instance of split being an empty string