0

Alright, I can't quite figure out how to do this.

Given the following text:

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

I'm trying to use the following:

/^([\w\d \-]*):\s\s\s\s^\/start([^\:]*)\/end$/im

You can see on rubular here:

http://rubular.com/r/BVRRHsnWdp

Thanks for any help. I guess I'm trying to match blocks of text until I hit the next title which always ends with a :$

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
codygman
  • 832
  • 1
  • 13
  • 30

2 Answers2

1

The problem with your solution is [^\:]* doesn't allow any colons in the paragraph, but there are some. Try this, using a non-greedy match for the paragraphs:

/^([\w\d \-]*):\s+^\/start(.*?)\/end$/im
mckeed
  • 9,719
  • 2
  • 37
  • 41
  • Thanks, I knew it was something with greedy/non-greedy as to why I was matching everything . Also, the \s+ was helpful, I can see why it was more useful. – codygman Apr 01 '10 at 22:44
0

Take a look at Ruby's "flip-flop" operator. It is very useful for this sort of problem.

"When would a Ruby flip-flop be useful?" covers this.

Community
  • 1
  • 1
the Tin Man
  • 158,662
  • 42
  • 215
  • 303