One of the jQuery Core Style Guidelines indicate:
All RegExp operations should be done using .test() and .exec().
“string”.match() is no longer used.
Why is match() not favoured?
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.
Because
.execis simply a better version of.matchLet’s see
If regexp is a non global regular expression then the return values are the same.
However if regexp is a global regular expression (
/foo/g) then match just returns an array of matches and that’s it. No extra meta data like exec would return!