regex - Replace filename using JavaScript? -


Can anyone show me how to do the following in javascript? I know how to get the source of the image, I just want to replace the file name with something new.

case-insensitive version:

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

Comments