Alex Rivera | Logout

How do I change file extension with javascript

Asked 2011-05-10T16:27:28.663
66

Does anyone know an easy way to change a file extension in Javascript?

For example, I have a variable with "first.docx" but I need to change it to "first.html".

Edit
Report

1 Answer

19
file = file.replace(/\.[^.]+$/, '.html');
answered 2011-05-10T16:34:10.180

Your Answer