exec() in JavaScript – How to Execute a RegExp Search
exec() executes a search for a regular expression pattern in its string argument.
exec() executes a search for a regular expression pattern in its string argument.
test() tests its string argument for an occurrence of a regular expression.