Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  90] [ 4]  / answers: 1 / hits: 15719  / 13 Years ago, thu, march 17, 2011, 12:00:00

Can someone show me how to do the following in JavaScript? I know how to grab the src of the image, I just want to be able to replace the filename with something new.




/image/any/path/ANY-TEXT_HERE.png



/image/any/path/NEWTEXT.png



More From » regex

 Answers
23

Case-insensitive version:



path = path.replace(/(.*)/.*(.png$)/i, '$1/NEWTEXT$2')


Remove the i after / to make it case-sensitive.


[#93237] Tuesday, March 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devinjadong

Total Points: 711
Total Questions: 117
Total Answers: 100

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
devinjadong questions
Thu, Feb 17, 22, 00:00, 2 Years ago
Wed, Dec 8, 21, 00:00, 2 Years ago
Tue, Oct 27, 20, 00:00, 4 Years ago
Fri, Oct 18, 19, 00:00, 5 Years ago
;