By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

remove '?' from a string

P: 31
I have a string value in a javascript function , as ' var a=abcd?' . I want to remove the '?' char which is at the end of the string. I tried with a.replace(/?/g,''); but it gives a error when loading the page. how can i do this.
May 14 '08 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,390
you have to escape the question mark since it is a quantifier for the regExp and you need it to be treated as a character:

Expand|Select|Wrap|Line Numbers
  1. a.replace(/\?/g,'')
kind regards
May 14 '08 #2

P: 31
thanks. it works perfectly.
May 14 '08 #3

gits
Expert Mod 5K+
P: 5,390
:) no problem ... post back to the forum anytime you have more questions ...

kind regards
May 14 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.