Regex - Finds one match for repeating patterns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm stumped...

I'm trying to find start and stop blocks in a string which use the same
markers. The problem is that it finds the very first start marker and very
last end marker and counts only 1 match when there are mutiple starts and
stops.

For instance my regex code would read something like :(?ixs)(start(.*)end)

My search string would be something like:

start
blah blah
end

start
blah blah
end

------------------------------

This would find the top and bottom, but doesn't see that there's two here.
I've spent an embarrassing amount of time on such a simple task. Can anyone
help?

Thanks
Richard Olson
 
Radioflyer651 said:
I'm trying to find start and stop blocks in a string which use the same
markers. The problem is that it finds the very first start marker and very
last end marker and counts only 1 match when there are mutiple starts and
stops.

For instance my regex code would read something like :(?ixs)(start(.*)end)

Just make your match non-greedy by using the ?, like this:

(?ixs)(start(.*?)end)
 
Back
Top