I want to remove extension of a file name. For example:
Demo.csv --> Demo
thermal.jpg --> thermal
I have used following regex but its not working.
/(.*)[^.]+$/
Kindly help, thanks in advance!
您可以尝试以下RegExp:
/.+\.([^.]+)$/
var str='thermal.jpg.png'; // double extension to test behavior
var name=str.substr(0,str.lastIndexOf('.')); // -> thermal.jpg
name=str.substr(0,str.indexOf('.')); // -> thermal
Hey thanks to all folks for your help!!! but this is the RegEXP which I got which is working in my scenario
^(.*\.)[^.]+$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.