S
S.Z.
I have a fragment like this:
variant= [ /[abc]/, /[123]/, /[xyz]/ ];
re= /aaa\s(#{variant.join('|')})\sbbb/;
mch= re.match($stdin.read);
(Remove the semicolons if you hate them.)
Now, I need to know what branch of variant is match, /[abc]/ or /[123]/
or /[xyz]/
How can I reveal it?
variant can be iterated with mch[1] :
vm= variant.find { |v| v.match(mch[1]); }
But it is superfluous work, isn't it?
variant= [ /[abc]/, /[123]/, /[xyz]/ ];
re= /aaa\s(#{variant.join('|')})\sbbb/;
mch= re.match($stdin.read);
(Remove the semicolons if you hate them.)
Now, I need to know what branch of variant is match, /[abc]/ or /[123]/
or /[xyz]/
How can I reveal it?
variant can be iterated with mch[1] :
vm= variant.find { |v| v.match(mch[1]); }
But it is superfluous work, isn't it?