Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  88] [ 3]  / answers: 1 / hits: 15579  / 12 Years ago, tue, may 29, 2012, 12:00:00

How can I insert a string before the extension in an image filename? For example, I need to convert this:



../Course/Assess/Responsive_Course_1_1.png


to this:



../Course/Assess/Responsive_Course_1_1_large.png

More From » string

 Answers
70

If we assume that an extension is any series of letters, numbers, underscore or dash after the last dot in the file name, then:



filename = filename.replace(/(.[wd_-]+)$/i, '_large$1');

[#85285] Monday, May 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marques

Total Points: 366
Total Questions: 108
Total Answers: 111

Location: Burundi
Member since Wed, Nov 25, 2020
4 Years ago
marques questions
;