What is the meaning of the g flag in regular expressions?
g
What is is the difference between /.+/g and /.+/?
/.+/g
/.+/
->
without g
example:
'1 2 1 5 6 7'.match(/\d+/)
["1", index: 0, input: "1 2 1 5 6 7", groups: undefined]
"1"
'1 2 1 5 6 7'.match(/\d+/g)
["1", "2", "1", "5", "6", "7"]