Quote: For example, /a+/g
would find one match in "abc"
and return ["a"]
. Because of the +
, it would also find a single match in "aabc"
and return ["aa"]
.
What will be returned? An array?
Quote: For example, /a+/g
would find one match in "abc"
and return ["a"]
. Because of the +
, it would also find a single match in "aabc"
and return ["aa"]
.
What will be returned? An array?
A regular expression just a pattern. There are different methods that use regular expressions and return values. Both .match()
(a string method) and .exec()
(a RegExp method) return arrays. .test()
(also a RegExp method) returns a boolean.
Thank you for the reply.