首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Regex来提取这个半格式化的数据。

Regex来提取这个半格式化的数据。
EN

Stack Overflow用户
提问于 2010-04-02 04:48:50
回答 2查看 142关注 0票数 0

好吧,我不太明白该怎么做。

给定以下文本:

代码语言:javascript
复制
Roland AX-1:


/start
Roland's AX-1 strap-on remote MIDI controller has a very impressive 45-note velocity sensitive keyboard, and has switchable velocity curves, goes octave up/down, transpose, split/layering zones, and has fun tempo control for sequencers and more. Roland's AX-1 comes with a built-in GS control for total MIDI control of GM/GS synths. Its "Expression Bar" can control pitch and mod via an almost ribbon-like controller. It's also the newest and most advanced remote controller for your synths or midi modules.
/end

Roland AX-7:

/start
Roland's AX-7 builds on the infamous Roland AX-1 design. You just strap it on and put it to the front of the stage. Offering several controllers, such as: a D-Beam, then you can open the door to amazing live performance. 7-segment LED display, larger patch memory (Around 128 patches with MIDI data backup), and comes with GM2/GS compatibility make it extra easy to use. The 45-note, velocity-sensitive keyboard. 5 realtime controllers including a data entry knob, touch controller knob, opression bar, a hold button, and D-Beam. 128 patches with MIDI data backup. 2 MIDI zones.
/end

我正在尝试使用以下内容:

代码语言:javascript
复制
/^([\w\d \-]*):\s\s\s\s^\/start([^\:]*)\/end$/im

你可以在这里看到红宝石:

http://rubular.com/r/BVRRHsnWdp

谢谢你的帮助。我猜我是在尝试匹配文本块,直到我找到下一个总是以:$结尾的标题

EN

回答 2

Stack Overflow用户

发布于 2010-04-02 04:58:31

你的解决方案的问题是[^\:]*不允许在段落中有冒号,但有一些冒号。试试这个,对段落使用非贪婪的匹配:

代码语言:javascript
复制
/^([\w\d \-]*):\s+^\/start(.*?)\/end$/im
票数 1
EN

Stack Overflow用户

发布于 2010-04-02 06:09:52

看看Ruby的"flip-flop“操作符。对于这类问题,它非常有用。

"When would a Ruby flip-flop be useful?“介绍了这一点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2563572

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档