Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  57] [ 7]  / answers: 1 / hits: 67587  / 12 Years ago, sat, may 5, 2012, 12:00:00

I have a variable that holds the value 'website.html'.



How can I split that variable so it only gives me the 'website'?



Thanks


More From » split

 Answers
11
var a = website.html;
var name = a.split(.)[0];


If the file name has a dot in the name, you could try...



var a = website.old.html;
var nameSplit = a.split(.);
nameSplit.pop();
var name = nameSplit.join(.);


But if the file name is something like my.old.file.tar.gz, then it will think my.old.file.tar is the file name


[#85769] Friday, May 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kieraelsies

Total Points: 718
Total Questions: 103
Total Answers: 104

Location: England
Member since Sun, May 21, 2023
1 Year ago
kieraelsies questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Tue, Feb 23, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Mon, Sep 16, 19, 00:00, 5 Years ago
;