ruby - Parsing command and arguments with a regex? -
i have little ruby cli should take command , arguments.
for example, should able do:
attribute value or:
attribute (value1, value2) or:
attribute (value1, value2) , attribute2 (value3, value4) or combination.
i'd like:
[['attribute', ['value1', 'value2']], ['attribute2', ['value3', 'value4']]] i came regex
(\b[a-z_]{1}\w+)\s{1}\((.*?)\) which gets me partially there, in matches attribute , both values (as whole, [['attribute', 'value1, value2']], doesn't match attribute value.
i dont know how extensive of input require, this might trick. works shell getopts.
ruby regex
No comments:
Post a Comment