Insert a string before the extension in a filename

后端 未结 7 1459
日久生厌
日久生厌 2021-02-05 03:58

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
相关标签:
7条回答
  • 2021-02-05 04:27

    Use javascript lastIndexOf, something like:

    var s = "Courses/Assess/Responsive_Cousre_1_1.png";
    var new_string = s.substring(0, s.lastIndexOf(".")) + "_large" + s.substring(s.lastIndexOf("."));
    
    0 讨论(0)
提交回复
热议问题