Q:

Extract all values matching a specific pattern

I have an input string 
var input = 'J1,J2, J3';

I'm using the following pattern to extract the group value
var regex = /(,? ?(? <JOUR>J[0-9]+)+)/

while extracting the groups as below
var match = regex.exec(input);

match.groups contains only one group.  How can i get all the groups J1 J2 and J3 from the input string ? 

A:

You can use .match of string to get groups
input.match(/J[0-9]+/g)

var input = 'J1,J2, J3';
console.log(input.match(/J[0-9]+/gi))

