I\'m new to JavaScript and have a question about regular expressions. I have the following code:
var patt3=new RegExp(/(July|August)\\s+\\d{1,2}(\\s|,)\\d{4}
Quoting the docs on String.match
:
If the regular expression does not include the g flag, returns the same result as regexp.exec(string).
If the regular expression includes the g flag, the method returns an Array containing all matches. If there were no matches, the method returns null.
In the second example, the first element of the array is the match, while the others are capturing groups. With g
, each element would be a different match.