How do i replace multiple instances of %20 in a filename ?

Hello,

At present i'm using the following Javascript to replace %20 with  " " (a blank space):

hs.captionEval = 'this.content.src.substring(this.content.src.lastIndexOf("/")).replace("/", "").replace(".jpg", "").replace("%20", " ")';

It works but it only replaces the first %20 rather than all of them, so that a long image filename now reads:
Hello to%20you%20my%20dear%20sir

How do i fix this?


Many thanks
www.globexposure.net/index.php
click on the England pushpin marker > Norwich arrow marker > home icon
DaniishAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
try:
hs.captionEval = 'this.content.src.substring(this.content.src.lastIndexOf("/")).replace("/", "").replace(".jpg", "").replace(/%20/g, " ")';
0
 
silemoneCommented:
use global reg expression that goes to end of line $ <--using end of line character and /g for globally change all over page...
0
 
hieloCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.