C
Charlie S
I need to match a block of text as follows
Discard all lines which begin with //
Capture all lines in between as single strings
So
// section 1
bit
bit more
// section 2
more stuff
// section 3
and yet more
Should yeild 3 strings:
[ bit\n\nbit more\n\n]
[\n\n\n more stuff\n\n]
[\n\n\nand yet more\n]
Can anyone help?
I've tried:
builds = s.scan(%r[\n//[^\n]*\n([^\n]*\n)+?]m)
but this yields
[ bit]
[\n]
[\n]
how can I make the group capture more than a line?
Discard all lines which begin with //
Capture all lines in between as single strings
So
// section 1
bit
bit more
// section 2
more stuff
// section 3
and yet more
Should yeild 3 strings:
[ bit\n\nbit more\n\n]
[\n\n\n more stuff\n\n]
[\n\n\nand yet more\n]
Can anyone help?
I've tried:
builds = s.scan(%r[\n//[^\n]*\n([^\n]*\n)+?]m)
but this yields
[ bit]
[\n]
[\n]
how can I make the group capture more than a line?