?
Solved

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

Posted on 2008-11-07
4
Medium Priority
?
1,363 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Daniish
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22907155
try:
hs.captionEval = 'this.content.src.substring(this.content.src.lastIndexOf("/")).replace("/", "").replace(".jpg", "").replace(/%20/g, " ")';
0
 
LVL 21

Expert Comment

by:silemone
ID: 22907168
use global reg expression that goes to end of line $ <--using end of line character and /g for globally change all over page...
0
 
LVL 21

Expert Comment

by:silemone
ID: 22907187
0
 
LVL 82

Expert Comment

by:hielo
ID: 22907353
glad to help
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question