使用 ruby 宝石列表进行 Grep
Grep with ruby the gemlist
我正在尝试 grep gem 列表。我得到列表
bundlelist = `bundle show`
结果
"Gems included by the bundle:\n * CFPropertyList (2.3.1)\n * abstract_type (0.0.7)\n * actionmailer (4.2.3)\n * actionpack (4.2.3)\n"
我愿意:
=> ["CFPropertyList",
"abstract_type",
"actionmailer",
"actionpack"]
当我尝试对其进行 grep 时,我会 bundlelist.scan(/\*.*\(/)
。结果是:
=> ["* CFPropertyList (",
"* abstract_type (",
"* actionmailer (",
"* actionpack ("]
改用回顾和回顾:
/(?<=\* ).*?(?= \()/
这个意思是前面是星号+space后面是space+左括号.
我正在尝试 grep gem 列表。我得到列表
bundlelist = `bundle show`
结果
"Gems included by the bundle:\n * CFPropertyList (2.3.1)\n * abstract_type (0.0.7)\n * actionmailer (4.2.3)\n * actionpack (4.2.3)\n"
我愿意:
=> ["CFPropertyList",
"abstract_type",
"actionmailer",
"actionpack"]
当我尝试对其进行 grep 时,我会 bundlelist.scan(/\*.*\(/)
。结果是:
=> ["* CFPropertyList (",
"* abstract_type (",
"* actionmailer (",
"* actionpack ("]
改用回顾和回顾:
/(?<=\* ).*?(?= \()/
这个意思是前面是星号+space后面是space+左括号.