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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -