Honestly, I really dislike regular expressions. Some people love them for
their terseness. I, on the other hand, being a pooh of very little brain,
spend far too many hair pulling hours just trying to get one of the dang
things right. Ugh.
Right now I'm working on this:
/^[ ]*[-](.*\n)+.*\n/
Applied to:
%Q{
- xyz
- abc
- not this
}
I want it to match just the first section, essentially
" - xyz\n - abc\n\n".
But it's matching the whole string. Can any of you Regexp experts fill me in?
David A. Black wrote:
> I think what you want is: match one or more consecutive occurrences
> of <space>-<stuff>\n, stopping when one of them has an extra \n at the
> end.
>
> Try this and see if it's close to what you need:
>
> /(^\ *-.*\n)+\n/
Umm... in the regexp as in the other, isn't an m needed at the end?
No, because if you put an /m, then the dot will match \n, and .* will
trample over the end of the lines. I'm using \n as a flag for
starting and stopping.