On Wed, Aug 02, 2000 at 12:27:58PM -0400, Ronald J Kimball wrote: > On Wed, Aug 02, 2000 at 08:54:55AM -0700, Randal L. Schwartz wrote: > > >>>>> "Jeff" == Jeff Pinyan <jeffp@crusoe.net> writes: > > > > Jeff> ($first) = $text =~ m{ > > Jeff> BEGIN > > Jeff> ( > > Jeff> [^BE]* # 'B' and 'E' are first chars of tags > > Jeff> (?: > > Jeff> (?: > > Jeff> B+ (?! EGIN ) # match /B+/ if NOT 'BEGIN' > > > I think yours fails on BEGIN ... BBBBBEGIN ... END ... END > > as well, since you grab the multiple B's but only check the first > > B for BEGIN'ness. :) > > I don't think that's right. B+(?!EGIN) checks each B for BEGIN-ness. > In BBBBEGIN, it will match the first three Bs and reject the fourth, which > is followed by EGIN. No, it checks to see if the last B is followed by EGIN. It will backtrack to a previous B only if it is. But the solution doesn't generalize. It relies on the fact that the second characters of the tokens are different from the first. There would be a problem if the you tried it with 'BBEGIN' and 'EEND' instead of 'BEGIN' and 'END'. Abigail ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe