regex - Grep with ruby the gemlist -
i'm trying grep gem list. list with
bundlelist = `bundle show` result
"gems included bundle:\n * cfpropertylist (2.3.1)\n * abstract_type (0.0.7)\n * actionmailer (4.2.3)\n * actionpack (4.2.3)\n" i like:
=> ["cfpropertylist", "abstract_type", "actionmailer", "actionpack"] when try grep on it, bundlelist.scan(/\*.*\(/). result is:
=> ["* cfpropertylist (", "* abstract_type (", "* actionmailer (", "* actionpack ("]
use lookbehind , lookahead instead:
/(?<=\* ).*?(?= \()/ what means minimum thing preceded star + space , followed space + opening bracket.
Comments
Post a Comment