I have:
var foo = '(bar)'
foo.replace('(', '').replace(')', '')
So, I get bar without parentheses, is there a better way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use:
That involves a simple regular expression that matches all instances of either open- or close-parentheses.
Note that you have to include that assignment, as “.replace()” does not modify the string; it returns the modified string.