test() method executes a search for a match between a regular expression and a specified string. Returns
RegExp objects are stateful when they have the
sticky flags set (e.g.,
/foo/y). They store a
lastIndex from the previous match. Using this internally,
test() can be used to iterate over multiple matches in a string of text (with capture groups).