I'm trying to use Regex to validate the form field data in javascript. The accepted patterns are for a single item, Org-1234 or for multiple, Org-1234, Org-56789. For multiple items, they have to be separated by comma (with potential space around it). The matching should be case insensitive.
I came up with this regex: /^(org-\d+)([ ,](org-\d+))*/i, however it only matches the first capture group. How could I make it work with an optional repeated pattern, i.e., if there is more character outside of the first match group, it has to conform with the same pattern, separated by comma?