remove quotes from string

S

soni2926

hi,
i have a page that has a search box, when the user types something
into i'm able grab the data, but wanted to strip out all the quotes
(double and single) from it, what's the best way to do that?
basically i need to pass the search words to another page via the url,
but want to strip the quotes out first.

Thanks.
 
D

David Mark

hi,
i have a page that has a search box, when the user types something
into i'm able grab the data, but wanted to strip out all the quotes
(double and single) from it, what's the best way to do that?
basically i need to pass the search words to another page via the url,
but want to strip the quotes out first.

Thanks.

Assuming you aren't passing the query to a static page, you need to do
this on the server side and it doesn't make sense to do it twice.
 
E

Evertjan.

wrote on 16 jul 2007 in comp.lang.javascript:
i have a page that has a search box, when the user types something
into i'm able grab the data, but wanted to strip out all the quotes
(double and single) from it, what's the best way to do that?
basically i need to pass the search words to another page via the url,
but want to strip the quotes out first.

<script type='text/javascript'>
function stripIt(x){
x.value = x.value.replace(/['"]/g,'');
};
</script>

<input onblur='stripIt(this);'>
 
F

ft310

wrote on 16 jul 2007 in comp.lang.javascript:
i have a page that has a search box, when the user types something
into i'm able grab the data, but wanted to strip out all the quotes
(double and single) from it, what's the best way to do that?
basically i need to pass the search words to another page via the url,
but want to strip the quotes out first.

<script type='text/javascript'>
function stripIt(x){
x.value = x.value.replace(/['"]/g,'');};

</script>

<input onblur='stripIt(this);'>

Be cautious -- this is an excellent suggestion if there are no
contracted words being passed. For instance O'Neil or Mc'Mann would
not be treated well.

If it is not too much trouble, I suggest making sure the process that
is using " or ' as markers is refined rather that just attempting a
blanket removal.

I have always found taking those things out without a full
understanding of the process results in enormous bites out of my
behind.
 
D

David Mark

wrote on 16 jul 2007 in comp.lang.javascript:
<script type='text/javascript'>
function stripIt(x){
x.value = x.value.replace(/['"]/g,'');};
</script>

<input onblur='stripIt(this);'>

Be cautious -- this is an excellent suggestion if there are no
contracted words being passed. For instance O'Neil or Mc'Mann would
not be treated well.

They will be treated just fine. As the OP stated, he "wanted to strip
out all the quotes (double and single)."
If it is not too much trouble, I suggest making sure the process that
is using " or ' as markers is refined rather that just attempting a
blanket removal.

I have always found taking those things out without a full
understanding of the process results in enormous bites out of my
behind.- Hide quoted text -

I've found that posting without carefully reading the thread will have
the same effect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top