Help with Regexp

I put together this note tag.


/<Index:[ ](.*), Copy:[ ](.*), Take:[ ](.*)>/i


Usage1: <Index: 5, Copy: 3, Take: 2>


Usage2: <Index: 2, Copy: 2, Take: 0>


Usage3: <Index: 3, Copy: 1,2,3, Take: 3,2>


The method which evaluates this note tag works something like this. (Don't take it too literally)


def method(id, index, copy, take)
index = index.scan(/(.*)/)[0][0].split(",")
take = take.scan(/(.*)/ )[0][0].split(",")
copy = copy.scan(/(.*)/ )[0][0].split(",")
return if index.compact.delete_if(&:empty?).empty?
unless copy.compact.delete_if(&:empty?).empty?
copy.each do |id|
next unless id.to_i > 0
/something happens/
end
end
unless take.compact.delete_if(&:empty?).empty?
take.each do |id|
next unless id.to_i > 0
/something happens/
end
end
/some more stuff happens/
end # method




What I want to know is; how do I make the 'copy' and 'take' input values optional for the note tag without making separate notes (and methods consequently)?


Like this: <Index: 2, Copy: 3,4,5>


Or this: <Index: 3, Take: 1, 2>


So that copy remains as $2, and take as $3 either way.


This isn't a necessity, but it would be a nice feature.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-regexp.65077/