I am trying to write some code that will look a the contents of a variable and remove “(?) ” if it is in the variable. The “?” could be any number, but I want to remove the parentheses, the content between them, and the space after.
Share
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.
This isn’t really a jQuery issue, but rather a JavaScript issue. Here’s one solution:
This results in
23234, since we matched a(, followed by a digit repeated (\d+), followed by another), followed by an optional space (\s). The second parameter shows that we’re replacing this matched pattern with nothing ('').