in reply to Perl pattern finding
Generally speaking, this sort of problem is often handled by using the features that allow you to match an item in a string and then remain in the position where the match occurred, so that subsequent regexes pick up where the others left off in the same string. So, this helps by allowing you to break down the problem into two smaller, but well-defined patterns: (a) a series of consecutive non-zero numbers; and (b) a series of four-or-more zeroes. Your basic approach, then, now uses if statements and other standard procedural-programming constructs in conjunction with these two regexes.
(pseudo-code) ... while (the first pattern matches) { $p = the ending position if (second pattern matches) { if (the first pattern matches again) { success! $p = the ending position now ... } } resume at $p }
Finally, if you find yourself doing a lot of this sort of thing, it is possible that you are starting to wander into the lands where Parse::RecDescent might be of service.