Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!elroy.jpl.nasa.gov!forsight!jato!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: how long is a {0,m} match? Message-ID: <8999@jpl-devvax.JPL.NASA.GOV> Date: 3 Aug 90 21:06:41 GMT References: <12170008@hpccc.HP.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 23 In article <12170008@hpccc.HP.COM> weisberg@hpccc.HP.COM (Len Weisberg) writes: : If there is some general principle about longest match, : it seems to break when 0 repetitions match, but only when : the match is not at the start of the string. : : Does this make sense? Is it a bug? Yes, it makes sense, and no, it isn't a bug. The longest match rule is subordinate to two other rules: 1. Find the leftmost match. 2. Given 1, find the first alternative that matches. 3. Given 1 and 2, find the longest match. (Rules 2 and 3 apply recursively inside parentheses.) Any item that can match 0 or more times will do so at the beginning of a string if the first thing in the string isn't a match. Larry