Solved

decode html query string in javascript using replace function

Posted on 2004-09-02
4
617 Views
Last Modified: 2009-07-29
hey i need a regular expression to pass into the jscript replace function.

all i'm trying to do is replace the %20 from the query string that gets passed over with the space that was originally there.  

thanks
0
Comment
Question by:das165227
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
darksinclair earned 200 total points
ID: 11963731
Could you just use strQuery = strQuery.split("%20").join(" "); ?
0
 

Author Comment

by:das165227
ID: 11963861
yeah that works too.  

i'm curious as to why this won't work though if anyone wants to post for the hek of it and since its pretty simple.  

var regExpression= /%20/;
text= text.replace(regExpression," ");
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 11965618
I'm not 100% sure on regular expressions.. but from what I know I think this is close to trim white spaces...

 var objRegExp = /^(\s*)$/;
0
 

Author Comment

by:das165227
ID: 11967342
i'm not wanting one to trim white spaces.  i was wanting one to look for the %20 in the jscript replace function.  i thought the code you gave me earlier worked but theres a problem with it somewhere.  i'm not sure where but its messing the html up somewhere that i'm passing over through the query string.  i'll post the question again
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

919 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now