0

When I test my regex online (like http://regex101.com), everything works fine. But when I test it in javascript, It doesn't. I don't understand what I'm doing wrong.

var input = 'fzef zef zef zef (,  ) dezdezfzef  ezf ze';
input = input.replace('/\(\,?\s{0,}?\)/g', '');
console.log(input);

Thank you

1 Answer 1

2

You need to remove the quotes from around your regex:

input.replace(/\(\,?\s{0,}?\)/g, '')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.