How can I trim the dot at the end of string in JS ?
Input:
const string = 'ABCD.txt'
Output:
const string = 'ABCD'
How can I do ?
Thanks for help me
How can I trim the dot at the end of string in JS ?
Input:
const string = 'ABCD.txt'
Output:
const string = 'ABCD'
How can I do ?
Thanks for help me
 
    
    const string  = "ABCD.txt";
const result =  string.replace(/\.[^/.]+$/, "");
 
    
    const index = string.lastIndexOf('.');
const before = string.slice(0, index);
