Is there a shorter way to write this?
var needed = /\$\[\w+\]/mi;
needed.compile(/\$\[\w+\]/mi);
Why do I have to pass the pattern back into the regex when I’ve already declared it in the first line?!
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.
There are two ways of defining regular expressions in JavaScript — one through an object constructor and one through a literal. The object can be changed at runtime, but the literal is compiled at load of the script, and provides better performance.
or more simply:
This is the same thing that cobbai is saying. In short, you do not have to do both.